我的代码用一个按钮调用一个窗口。单击按钮时,调用另一个窗口。但是第二个窗口立即关闭
“basic”和“windows_two”是pyuic5从.ui文件生成的.py库
import basic, windows_two
from PyQt5 import QtCore, QtGui, QtWidgets
if __name__ == "__main__":
#Declarations
import sys
app = QtWidgets.QApplication(sys.argv)
def Call_Second_Window():
#Second Screen
Form = QtWidgets.QWidget()
ui = windows_two.Ui_Form()
ui.setupUi(Form)
Form.show()
def Call_Main_Window():
#MainWindow
MainWindow = QtWidgets.QMainWindow()
ui = basic.Ui_MainWindow()
ui.setupUi(MainWindow)
ui.printButton.clicked.connect(Call_Second_Window) #click event to second window
MainWindow.show()
sys.exit(app.exec_())
Call_Main_Window()
怎么了?
谢谢