-
Notifications
You must be signed in to change notification settings - Fork 0
/
test4.py
40 lines (26 loc) · 878 Bytes
/
test4.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
32
33
34
35
36
37
38
39
40
import sys
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWidgets import QHBoxLayout
from PyQt5.QtWidgets import QLabel
from PyQt5.QtWidgets import QPushButton
import random
c40e0e
class Label(QLabel):
def __init__(self):
super(Label, self).__init__()
self.letters = ['q','w','e','r','t','y']
self.h_layout = QHBoxLayout()
self.setLayout(self.h_layout)
self.label = QLabel('Random letters: _')
self.btn = QPushButton("Roll")
self.btn.clicked.connect(self.change_label)
self.h_layout.addWidget(self.label)
self.h_layout.addWidget(self.btn)
def change_label(self):
if len(self.letters)>0:
self.label.setText(self.letters.pop(0))
if __name__=="__main__":
app = QApplication(sys.argv)
main_label = Label()
main_label.show()
sys.exit(app.exec_())