i Make program to show Message and after sometime change the Message but If you close the program, it does not close only close window , Please help how to Close All Codes
This Code:
from PyQt5.QtWidgets import *
from PyQt5 import QtCore,QtGui
from threading import Timer
class s:
def UI(self, window):
window.setFixedHeight(500)
window.setFixedWidth(600)
self.Label = QLabel(window)
self.Label.setGeometry(0, 0, 600, 500)
self.Label.setAlignment(QtCore.Qt.AlignCenter)
self.Label.setStyleSheet('font-size:100px')
def mone():
self.Label.setText('Hello')
Tim = Timer(3, mtwo)
Tim.start()
def mtwo():
Tim = Timer(3, mthree)
self.Label.setText('World')
Tim.start()
def mthree():
Tim = Timer(1, mfour)
self.Label.setText('To')
Tim.start()
def mfour():
Tim = Timer(1.5, mfive)
self.Label.setText('My')
Tim.start()
def mfive():
Tim = Timer(10, mone)
self.Label.setText('Program')
Tim.start()
mone()
def pd(self):
print('d')
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
form = QMainWindow()
sd = s()
sd.UI(form)
form.show()
sys.exit(app.exec_())
You could try using a QtCore.QTimer
instead of a threading.Timer
, eg (note that the time interval in QTimer
is in ms)
def mone():
self.Label.setText('Hello')
QtCore.QTimer.singleShot(3000, mtwo)
def mtwo():
QtCore.QTimer.singleShot(3000, mthree)
self.Label.setText('World')
def mthree():
QtCore.QTimer.singleShot(1000, mfour)
self.Label.setText('To')
def mfour():
QtCore.QTimer.singleShot(1500, mfive)
self.Label.setText('My')
def mfive():
QtCore.QTimer.singleShot(10000, mone)
self.Label.setText('Program')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.