Show More
@@ -0,0 +1,37 b'' | |||||
|
1 | #!/usr/bin/env python | |||
|
2 | """Simple Qt4 example to manually test event loop integration. | |||
|
3 | ||||
|
4 | This is meant to run tests manually in ipython as: | |||
|
5 | ||||
|
6 | In [5]: %gui qt | |||
|
7 | ||||
|
8 | In [6]: %run gui-qt.py | |||
|
9 | ||||
|
10 | Ref: Modified from http://zetcode.com/tutorials/pyqt4/firstprograms/ | |||
|
11 | """ | |||
|
12 | ||||
|
13 | import sys | |||
|
14 | from PyQt4 import QtGui, QtCore | |||
|
15 | ||||
|
16 | class SimpleWindow(QtGui.QWidget): | |||
|
17 | def __init__(self, parent=None): | |||
|
18 | QtGui.QWidget.__init__(self, parent) | |||
|
19 | ||||
|
20 | self.setGeometry(300, 300, 200, 80) | |||
|
21 | self.setWindowTitle('Hello World') | |||
|
22 | ||||
|
23 | quit = QtGui.QPushButton('Close', self) | |||
|
24 | quit.setGeometry(10, 10, 60, 35) | |||
|
25 | ||||
|
26 | self.connect(quit, QtCore.SIGNAL('clicked()'), | |||
|
27 | self, QtCore.SLOT('close()')) | |||
|
28 | ||||
|
29 | if __name__ == '__main__': | |||
|
30 | app = QtCore.QCoreApplication.instance() | |||
|
31 | if app is None: | |||
|
32 | app = QtGui.QApplication([]) | |||
|
33 | ||||
|
34 | sw = SimpleWindow() | |||
|
35 | sw.show() | |||
|
36 | ||||
|
37 | app.exec_() |
General Comments 0
You need to be logged in to leave comments.
Login now