Я хочу сделать простое GUI-приложение на PyQt. Когда кнопка нажата, вы должны перейти на следующую страницу. Это как диалоги установки, которые вы знаете при установке программы.
Я пытался открыть новое окно в той же позиции, что и MainWindow, но это не так.
Так вот мой код:
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)