我想在PyQt中制作一个简单的GUI应用程序。当一个按钮被点击时,它会带你进入下一个页面。就像安装程序时知道的这些安装对话框。在
我试图在与主窗口完全相同的位置打开一个新窗口,但感觉不对。在
苏,这是我的密码:
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.title = "MainWindow"
# Here are some height & width variables
self.initUI()
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
self.UiComponents()
def UiComponents(self):
self.searchButton = QPushButton("", self)
# alot of UiComponents go here
self.searchButton.clicked.connect(self.make_handleButton("searchButton"))
def make_handleButton(self, button):
def handleButton():
if button == "searchButton":
### here it should go to SearchWindow ###
#elif button == "importButton":
# self.importWindow()
return handleButton
class SearchWindow(QMainWindow):
def __init__(self):
super().__init__()
self.title = "Search for something"
# Here are some height & width variables
self.initUI()
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
self.UiComponents()
self.hide()
def goToMain(self):
### here it should go back to the MainWindow ###
def UiComponents(self):
self.backButton = QPushButton("BackButton", self)
self.backButton.setGeometry(QRect(5, 5, self.backButtonWidth, self.backButtonHeight))
self.backButton.clicked.connect(self.goToMain)
我建议你不要使用pyqt5,它太复杂了,也不要因此讨厌编程。用python编写代码好吗?在python中使用argparse,这样我们就可以在终端调用它,然后创建visualstudio并打开c#project设计自己的ui,然后使用args调用.py文件。在
这是我的c调用python进程代码。试试这个,喜欢编程。简单想想。祝你有美好的一天。在
您必须使用QStackWidget,下面是一个示例:
相关问题 更多 >
编程相关推荐