Przeglądaj źródła

ENH: Added test for ctkAbstractPythonManager::executeString wrapping

Andras Lasso 9 lat temu
rodzic
commit
449b87e21e

+ 10 - 0
Applications/ctkSimplePythonShell/Testing/Python/ctkWidgetsTest.py

@@ -2,9 +2,19 @@
 from ctk import *
 from qt import QTimer
 
+# Test display of a CTK widget
 w = ctkMatrixWidget()
 w.show()
 
+# Test command execution using Python manager
+pythonManager = _ctkPythonManagerInstance
+pythonManager.executeString("variableInPythonConsole=523")
+try:
+  print("variableInPythonConsole was successfully set to {0}".format(variableInPythonConsole))
+except:
+  print "PythonManager.executeString failed"
+  qt.QApplication.exit(1)
+
 if not _ctkPythonConsoleInstance.isInteractive:
   #QTimer().singleShot(0, app(), SLOT('quit()'))
   t = QTimer()

+ 1 - 0
Applications/ctkSimplePythonShell/ctkSimplePythonShellMain.cpp

@@ -117,6 +117,7 @@ int main(int argc, char** argv)
     console.completer()->setAutocompletePreferenceList(list);
 
     pythonManager.addObjectToPythonMain("_ctkPythonConsoleInstance", &console);
+    pythonManager.addObjectToPythonMain("_ctkPythonManagerInstance", &pythonManager);
 
     ctkTestWrappedQProperty testWrappedQProperty;
     pythonManager.addObjectToPythonMain("_testWrappedQPropertyInstance", &testWrappedQProperty);