0%

pythonQt5示例

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
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton

class Example(QWidget):

def __init__(self):
super().__init__()
self.initUI()

def initUI(self):
btn = QPushButton('Button', self)
btn.clicked.connect(self.buttonClicked)
btn.resize(btn.sizeHint())
btn.move(50, 50)

self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('Signal and slot')
self.show()

def buttonClicked(self):
print('Button clicked!')

if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())