-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hi.py
52 lines (40 loc) · 1.3 KB
/
Hi.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
41
42
43
44
45
46
47
48
49
50
51
52
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QLabel
from PyQt5.QtWidgets import QLCDNumber
from random import choice
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
self.x = choice(range(10))
self.y = choice(range(10))
self.z = choice(range(10))
self.steps = 10
def initUI(self):
self.setGeometry(300, 300, 300, 300)
self.setWindowTitle('Числовая игра')
self.plus = QPushButton('+' + str(self.y), self)
self.plus.resize(self.plus.sizeHint())
self.plus.move(170, 150)
self.plus.clicked.connect(self.P)
self.minus = QPushButton('-' + str(self.z), self)
self.minus.resize(self.minus.sizeHint())
self.minus.move(20, 150)
self.minus.clicked.connect(self.M)
self.label = QLabel(self)
self.label.setText(str(self.x))
self.label.move(80, 30)
self.LCD_count = QLCDNumber(self.x, self)
self.LCD_count.move(110, 80)
self.count = 0
def P(self):
self.x += self.y
self.steps -= 1
def M(self):
self.x -= self.z
self.steps -= 1
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
ex.show()
sys.exit(app.exec())