我试图通过点击Python第三方GUI包PySide中当前窗口的按钮进入另一个窗口。
在MainWindow类中,单击“下一个窗口按钮”后,它将转到 NewWindow类创建一个新窗口。
问题是新窗口弹出大约一秒钟。
import sys
from PySide.QtCore import *
from PySide.QtGui import *
class NewWindow(QWidget):
def __init__(self):
super(NewWindow, self).__init__()
self.LLayout = QGridLayout()
self.btn2 = QPushButton('Present Window')
self.LLayout.addWidget(self.btn2)
self.setLayout(self.LLayout)
self.setWindowTitle('My SWindow')
self.show()
class MainWindow(QWidget):
def __init__(self):
super(MainWindow, self).__init__()
self.WLayout = QGridLayout()
self.btn = QPushButton('Next Window')
self.btn.clicked.connect(self.windowfunction)
self.WLayout.addWidget(self.btn)
self.setLayout(self.WLayout)
self.setWindowTitle('My FWindow')
self.show()
def windowfunction(self):
new_window = NewWindow()
def main():
app = QApplication(sys.argv)
main = MainWindow()
sys.exit(app.exec_())
main()