I want to make a simple GUI-App in PyQt. When a button gets clicked, it should take you to the next page. It's like these installations dialoges you know when installing a program.
I tried to open a new window at the exact same position like the MainWindow, but that doesen't feel right.
Soo, here's my code:
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)