关闭当前窗口,并在pyqt的条件下打开新窗口
如何关闭当前窗口并打开新窗口(如果条件为true)(没有任何按钮),然后再次运行孔脚本。我尝试了很多方法,但没有成功
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
.....
if __name__ == "__main__":
# print(deivce_data)
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
if deivce_data == data:
'''if this condition is true close the current window and run script again'''
How to close the current window and open new window if condition is true(without any button clicked) and run the hole script again. I have tried so many method but not success
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
.....
if __name__ == "__main__":
# print(deivce_data)
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
if deivce_data == data:
'''if this condition is true close the current window and run script again'''
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过控制qapplication()的执行句柄来做到这一点。
希望这会有所帮助。
You can do this by controlling the execution handle of QApplication().
Hope this helps.