问题描述
一个基本的例子,我试图调用 close() 方法来关闭主窗口,但没有关闭窗口,我必须手动关闭它。
from PyQt5 import QtWidgets
import sys
class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Should close")
self.close()
app=QtWidgets.QApplication(sys.argv)
w=MainWindow()
w.show()
app.exec_()
如果我将 self.show()
放在 init 方法中,而不是使用 w.show()
,窗口将打开和关闭,但程序不会停止运行。如何自动关闭窗口和应用程序?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)