Commits

Yuya Nishihara committed 5bfe3b7

pyqt: quitest: little example to click button

  • Participants
  • Parent commits 43be102

Comments (0)

Files changed (1)

File pyqt/guitest/dialog.py

 
 import sys
 from PyQt4.QtGui import QApplication, QWidget, QIcon, QFont, QToolTip, QPushButton, QMessageBox, qApp
-from PyQt4.QtCore import QObject, SIGNAL, SLOT
+from PyQt4.QtCore import QObject, QTimer, Qt, SIGNAL, SLOT
+from PyQt4.QtTest import QTest
 
 class MainWindow(QWidget):
     def __init__(self, parent=None):
         self.setToolTip('Welcome to <b>Simple</b> widget.')
         QToolTip.setFont(QFont('Serif', 12))
 
-        self.__quitButton = QPushButton('Quit', self)
-        self.__quitButton.move(100, 100)
-        QObject.connect(self.__quitButton, SIGNAL('clicked()'), qApp, SLOT('quit()'))
+        self._quitButton = QPushButton('Quit', self)
+        self._quitButton.move(100, 100)
+        QObject.connect(self._quitButton, SIGNAL('clicked()'), qApp, SLOT('quit()'))
 
     def closeEvent(self, event):
         reply = QMessageBox.question(self, 'Confirmation', 'Are you sure to quit?', QMessageBox.Yes, QMessageBox.No)
     w = MainWindow()
     w.show()
 
+    # TODO by remote request
+    QTimer.singleShot(1000,
+                      lambda: QTest.mouseClick(w._quitButton, Qt.LeftButton))
+
     return app.exec_()