Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
788 B
1
Indexable
Never
from PyQt5.QtCore import  Qt
from PyQt5.QtWidgets import *
from random import *

app = QApplication([])

my_win = QWidget()
my_win.setWindowTitle("Определить победителя")
my_win.move(100,100)
my_win.resize(400,200)

button = QPushButton("Сгенерировать")
text = QLabel("Нажми чтобы узнать победителя")
winner = QLabel("?")

line = QVBoxLayout()
line.addWidget(text, aligment=Qt.AlignCenter)
line.addWidget(winner, aligment=Qt.AlignCenter)
line.addWidget(button, aligment=Qt.AlignCenter)

my_win.setLayout(line)

def show_winner():
    number = randint(0, 99)
    winner.setText(str(number))
    text.setText(str("Победитель:"))

button.clicked.connect(show_winner)

my_win.show()
app.exec()
Leave a Comment