我的问题是,如果打开另一个文件中的窗口。py它会打开,但它会在不到一秒钟的时间内自动关闭 我尝试从相同的基本文件正常打开
示例: 此文件为first.py:
from PyQt5.QtWidgets import *
from anotherfile import UIAnother
class UIFirst:
def __init__(self, window):
window.resize(600, 600)
button = QPushButton('Open', window)
button.clicked.connect(self.Open)
def Open(self):
form = QMainWindow()
Ui = UIAnother(form)
form.show()
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
form = QMainWindow()
Ui = UIFirst(form)
form.show()
sys.exit(app.exec_())
和Anotherfile.py:
from PyQt5.QtWidgets import *
class UIAnother:
def __init__(self, window):
window.resize(600, 600)
button = QPushButton('Open', window)
我的使用Windows的程序需要拆分程序。并谢谢你