derivedQWidgetTest.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from qt import *
  2. class ExampleWidget(QWidget):
  3. def __init__(self, parent=None):
  4. QWidget.__init__(self, parent)
  5. self.setGeometry(300, 300, 250, 150)
  6. self.setWindowTitle('Example Widget')
  7. layout = QHBoxLayout(self)
  8. checkbox = QCheckBox('Shell Visibility', self)
  9. layout.addWidget(checkbox);
  10. checkbox.setChecked(True)
  11. checkbox.connect('toggled(bool)', _ctkPythonConsoleInstance, 'setVisible(bool)')
  12. self.button = QPushButton('Quit', self)
  13. layout.addWidget(self.button);
  14. QObject.connect(self.button, SIGNAL('clicked()'), app(), SLOT('quit()'))
  15. self.center()
  16. def center(self):
  17. screen = QDesktopWidget().screenGeometry()
  18. size = self.geometry
  19. self.move((screen.width() - size.width())/2, (screen.height() - size.height())/2)
  20. w = ExampleWidget()
  21. w.show()
  22. if not _ctkPythonConsoleInstance.isInteractive:
  23. #QTimer().singleShot(250, app(), SLOT('quit()'))
  24. t = QTimer()
  25. t.setInterval(250)
  26. t.connect('timeout()', app(), 'quit()')
  27. t.start()