-----------------------------------------------------------------------------
| 79 | |
| 80 | //----------------------------------------------------------------------------- |
| 81 | int main(int argc, char** argv) |
| 82 | { |
| 83 | #ifdef CTK_WRAP_PYTHONQT_USE_VTK |
| 84 | vtkDebugLeaks::SetExitError(true); |
| 85 | ctkTestWrappedVTKObserver testWrappedVTKObserver; |
| 86 | #endif |
| 87 | |
| 88 | int exitCode = EXIT_FAILURE; |
| 89 | { |
| 90 | QApplication app(argc, argv); |
| 91 | |
| 92 | ctkCommandLineParser parser; |
| 93 | // Use Unix-style argument names |
| 94 | parser.setArgumentPrefix("--", "-"); |
| 95 | |
| 96 | // Add command line argument names |
| 97 | parser.addArgument("help", "h", QVariant::Bool, "Print usage information and exit."); |
| 98 | parser.addArgument("interactive", "I", QVariant::Bool, "Enable interactive mode"); |
| 99 | |
| 100 | // Parse the command line arguments |
| 101 | bool ok = false; |
| 102 | QHash<QString, QVariant> parsedArgs = parser.parseArguments(QCoreApplication::arguments(), &ok); |
| 103 | if (!ok) |
| 104 | { |
| 105 | QTextStream(stderr, QIODevice::WriteOnly) << "Error parsing arguments: " |
| 106 | << parser.errorString() << "\n"; |
| 107 | return EXIT_FAILURE; |
| 108 | } |
| 109 | |
| 110 | // Show a help message |
| 111 | if (parsedArgs.contains("help") || parsedArgs.contains("h")) |
| 112 | { |
| 113 | QTextStream(stdout, QIODevice::WriteOnly) << "ctkSimplePythonShell\n" |
| 114 | << "Usage\n\n" |
| 115 | << " ctkSimplePythonShell [options] [<path-to-python-script> ...]\n\n" |
| 116 | << "Options\n" |
| 117 | << parser.helpText(); |
| 118 | return EXIT_SUCCESS; |
| 119 | } |
| 120 | |
| 121 | ctkSimplePythonManager pythonManager; |
| 122 | |
| 123 | ctkPythonConsole console; |
| 124 | console.initialize(&pythonManager); |
| 125 | |
| 126 | QMainWindow * mainWindow = new QMainWindow(); |
| 127 | mainWindow->setCentralWidget(&console); |
| 128 | mainWindow->resize(600, 280); |
| 129 | mainWindow->show(); |
| 130 | |
| 131 | QLabel cursorPositionLabel; |
| 132 | mainWindow->statusBar()->addWidget(&cursorPositionLabel); |
| 133 | |
| 134 | ctkCallback cursorPositionChangedCallback; |
| 135 | cursorPositionChangedCallback.setCallbackData(&console); |
| 136 | cursorPositionChangedCallback.setCallback(onCursorPositionChanged); |
| 137 | QObject::connect(&console, SIGNAL(cursorPositionChanged()), |
| 138 | &cursorPositionChangedCallback, SLOT(invoke())); |
nothing calls this directly
no test coverage detected