Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我能';t退出程序,只需关闭窗口pyqt5_Python_Pyqt_Pyqt5 - Fatal编程技术网

Python 我能';t退出程序,只需关闭窗口pyqt5

Python 我能';t退出程序,只需关闭窗口pyqt5,python,pyqt,pyqt5,Python,Pyqt,Pyqt5,我制作了一个程序来显示信息,并且在某个时候更改了信息,但是如果您关闭该程序,它不会只关闭“关闭”窗口,请帮助如何关闭所有代码 此代码: from PyQt5.QtWidgets import * from PyQt5 import QtCore,QtGui from threading import Timer class s: def UI(self, window): window.setFixedHeight(500) window.setFixed

我制作了一个程序来显示信息,并且在某个时候更改了信息,但是如果您关闭该程序,它不会只关闭“关闭”窗口,请帮助如何关闭所有代码

此代码:

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_())

您可以尝试使用
QtCore.QTimer
而不是
threading.Timer
,例如(请注意
QTimer
中的时间间隔以毫秒为单位)


这是工作,但不是重新加载我的意思是每次都需要重新加载,直到程序停止运行。重新加载是什么意思?您是否也更换了其他函数中的计时器?编辑:为完整起见,我已将
mtwo
的更新版本添加到
mfive
中。它正在工作,非常感谢,但由于我的原因出现了错误
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')