-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
46 lines (35 loc) · 1.17 KB
/
Copy pathmain.py
File metadata and controls
46 lines (35 loc) · 1.17 KB
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
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QLabel, QVBoxLayout
from PyQt5.QtCore import Qt
from random import randint
app = QApplication([]) # збереження додатка
window = QWidget()
window.resize(250,250) # розміри
window.move(250,250) # розміщення в коодинатах
button = QPushButton('кнопка') # віджет кнопка
text1 = QLabel('натисни') #текстовий віджет
text2 = QLabel('?')
v = QVBoxLayout() # Вертикальний лайаут
v.addWidget(text1, alignment=Qt.AlignCenter)
v.addWidget(text2, alignment=Qt.AlignCenter)
v.addWidget(button, alignment=Qt.AlignCenter)
def random_number():
n = randint(1,101)
text2.setText(str(n))
button.clicked.connect(random_number)
button.setStyleSheet ("""
background-color: violet;
border-radius: 10px;
font-size: 10px;
border-color: black;
padding: 10px 20px;
""")
window.setStyleSheet ("""
background-color: yellow;
border-radius: 10px;
font-size: 10px;
border-color: black;
padding: 10px 20px;
""")
window.setLayout(v)
window.show()
app.exec_()