I would like to press a button in a window and close that window,after that open a new window
How can I do it?
I already tried it but it sends this message the console:
QCoreApplication::exec: The event loop is already running
class Window(QWidget):
def __init__(self,parent = None):
super().__init__(parent)
self.title = 'pySim Z-eighty'
self.left = 0
self.top = 0
self.width = 1200
self.height = 3000
self.initUI()
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
self.button = QPushButton("Z80")
self.button1 = QPushButton()
self.button2 = QPushButton()
self.container = QWidget()
self.layout = QGridLayout()
self.layout.addWidget(self.button1, 1, 0)
self.layout.addWidget(self.button, 1, 1)
self.layout.addWidget(self.button2, 1, 2)
self.container.setLayout(self.layout)
self.layoutPrincipal = QBoxLayout(0)
self.layoutPrincipal.addWidget(self.container)
self.setLayout(self.layoutPrincipal)
self.button.pressed.connect(self.IniciarInterfaz)
def IniciarInterfaz(self):
self.hide()
app = QApplication(sys.argv)
ex = mainWindow()
ex.setStyleSheet("background-color: #fff")
ex.show()
sys.exit(app.exec_())
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Window()
ex.show()
sys.exit(app.exec_())
My main problem is when i pressed the button I can't open the new window
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…