小编Pie*_*ers的帖子

如何重新启动pyqt应用程序?

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *


class MainWindow(QMainWindow):
       EXIT_CODE_REBOOT = -123

#constructor
       def __init__(self):
            super().__init__() #call super class constructor
            #above is the constructor ^^^^^^^^^^^
            self.HomePage() #this goes to the homepage function

def HomePage(self):
    #this layout holds the review question 1
    self.quit_button_11 = QPushButton("restart", self)
    self.quit_button_11.clicked.connect(self.restart)

def restart(self):  # function connected to when restart button clicked
    qApp.exit( MainWindow.EXIT_CODE_REBOOT )


if __name__=="__main__":
currentExitCode = MainWindow.EXIT_CODE_REBOOT
while currentExitCode == MainWindow.EXIT_CODE_REBOOT:
    a = QApplication(sys.argv)
    w = MainWindow()
    w.show()
    currentExitCode = …
Run Code Online (Sandbox Code Playgroud)

pyqt pyqt4

2
推荐指数
2
解决办法
3744
查看次数

标签 统计

pyqt ×1

pyqt4 ×1