【发布时间】:2020-03-08 10:56:16
【问题描述】:
所以我想在 PyQt5 中有多个页面;例如,当我单击一个按钮时,它会转换到另一个页面。这是我的代码。
import sys
from PyQt5.QtWidgets import (QWidget, QPushButton,
QHBoxLayout, QVBoxLayout, QApplication)
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
Button = QPushButton("OK")
hbox = QHBoxLayout()
hbox.addStretch(1)
hbox.addWidget(Button)
vbox = QVBoxLayout()
vbox.addStretch(1)
vbox.addLayout(hbox)
self.setLayout(vbox)
self.setGeometry(300, 300, 300, 150)
self.setWindowTitle('Buttons')
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
我希望当我单击按钮时,它会转换到另一个页面,其中有另一个按钮,如果我按下它将转换回初始页面。
【问题讨论】:
标签: python-3.x pyqt5