Commits

Yuya Nishihara committed 43be102

pyqt: copy simple dialog to guitest

Comments (0)

Files changed (1)

pyqt/guitest/dialog.py

+#!/usr/bin/env python
+
+import sys
+from PyQt4.QtGui import QApplication, QWidget, QIcon, QFont, QToolTip, QPushButton, QMessageBox, qApp
+from PyQt4.QtCore import QObject, SIGNAL, SLOT
+
+class MainWindow(QWidget):
+    def __init__(self, parent=None):
+        super(QWidget, self).__init__(parent)
+        self.resize(250, 250)
+        self.setWindowTitle('Simple')
+        self.setWindowIcon(QIcon('/usr/share/pixmaps/python.xpm'))
+        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()'))
+
+    def closeEvent(self, event):
+        reply = QMessageBox.question(self, 'Confirmation', 'Are you sure to quit?', QMessageBox.Yes, QMessageBox.No)
+        if reply != QMessageBox.Yes:
+            event.ignore()
+        else:
+            event.accept()
+
+
+def main():
+    app = QApplication(sys.argv)
+    w = MainWindow()
+    w.show()
+
+    return app.exec_()
+
+
+if __name__ == '__main__':
+    exit_code = main()
+    sys.exit(exit_code)