-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path1_pushbutton.py
31 lines (25 loc) · 876 Bytes
/
1_pushbutton.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
import sys
from PyQt4 import QtGui
class MainWindow(QtGui.QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.init_ui()
def init_ui(self):
self.setWindowTitle('PyQt4 pushbutton Example')
print_button = QtGui.QPushButton("print 'hello, world'", self)
print_button.clicked.connect(self.print_hello_world)
central_widget = QtGui.QWidget()
central_layout = QtGui.QVBoxLayout()
central_layout.addWidget(print_button)
central_widget.setLayout(central_layout)
self.setCentralWidget(central_widget)
def print_hello_world(self):
print 'hello, world'
def main():
application = QtGui.QApplication(sys.argv)
main_window = MainWindow()
main_window.show()
sys.exit(application.exec_())
if __name__ == '__main__':
main()