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
| #!/usr/bin/env python3
from PyQt6.QtCore import *
from PyQt6.QtWidgets import *
class MyButton:
def __init__(self) -> None:
self.__btn = QPushButton('Soumettre réponses')
self.__btn.setFixedSize(QSize(400, 48))
self.__btn.setDisabled(True)
def get(self):
return self.__btn
def activate(self):
print("bouton activé")
self.__btn.setDisabled(False)
self.__btn.setStyleSheet(
"padding: 8px; margin-left:100px; background-color:#00af3b; color:white; border:none; font-size:16px"
)
class MyTimer(MyButton):
def __init__(self, btn):
super().__init__()
self.__reading_time: int = 5000 # 5 secondes
self.__btn=btn
def start(self):
print("start")
QTimer.singleShot(self.__reading_time, self.__btn.activate)
app=QApplication([])
chrono = MyTimer(MyButton())
chrono.start()
app.exec() |
Partager