Drama
21st January 2016, 02:16
Im making an app that has 2 menus, the first one is a "Welcome" menu, and the second one is for searching something. The problem is that i cant make the searching window show itself. It sticks in the welcome menu. When i started programming the tools for the searching window i kept them in the "Welcome" menu and worked fine until i tried to put those tools in an other menu(ergo different function); So i guess the problem is not that im not calling the self.show() because they worked fine before...
Here's the details of the app and what im doing. Gonna delete the non important parts.
Its kinda complex:
First i have this:
class Window(QtGui.QMainWindow):
def __init__(self):
super(Window, self).__init__()
self.buttons()
self.toolButtons()
self.searchMenu()
There there is the buttons() that creates all the interface of the "Welcome" menu, which was the first one.
toolButtons() explains itself. Im using one of the toolbuttons to switch between menues.
searchMenu() is the second Menu, which is supposed to show itself when you press one of the toolbuttons
A little bit later i have the important functions among others:
def buttons(self):
# Welcome menu. Images and labels.
self.show()
def toolButtons(self):
# Toolbuttons. Here is the button that is supposed to load the search menu, and it does it with these lines:
searchButton = QtGui.QAction(QtGui.QIcon('searchicon.png'), 'Search', self)
searchButton.triggered.connect(self.loadingSearchW indow) #Appears down
self.toolBar.addAction(searchButton)
def searchMenu(self):
# lot of comboboxes, images, etc. Loads everything of the search menu.
self.show()
____________________
Now here is the "loadingSearchWindow" that appears up in the searchButton:
def loadingSearchWindow(self):
search = self.searchMenu()
self.setCentralWidget(search)
So when you click the searchButton, it loads "loadingSearchWindow" which sets the searchMenu() as the CentralWidget.
And again, nothing happends when i click the toolButton that is supposed to load the search menu. And i dont know why, because im doing the same thing with the "buttons" function that loads the welcome menu without problems, but then it seems that if you want to add an other menu it doesn't work.
What am I doing wrong?
Here's the details of the app and what im doing. Gonna delete the non important parts.
Its kinda complex:
First i have this:
class Window(QtGui.QMainWindow):
def __init__(self):
super(Window, self).__init__()
self.buttons()
self.toolButtons()
self.searchMenu()
There there is the buttons() that creates all the interface of the "Welcome" menu, which was the first one.
toolButtons() explains itself. Im using one of the toolbuttons to switch between menues.
searchMenu() is the second Menu, which is supposed to show itself when you press one of the toolbuttons
A little bit later i have the important functions among others:
def buttons(self):
# Welcome menu. Images and labels.
self.show()
def toolButtons(self):
# Toolbuttons. Here is the button that is supposed to load the search menu, and it does it with these lines:
searchButton = QtGui.QAction(QtGui.QIcon('searchicon.png'), 'Search', self)
searchButton.triggered.connect(self.loadingSearchW indow) #Appears down
self.toolBar.addAction(searchButton)
def searchMenu(self):
# lot of comboboxes, images, etc. Loads everything of the search menu.
self.show()
____________________
Now here is the "loadingSearchWindow" that appears up in the searchButton:
def loadingSearchWindow(self):
search = self.searchMenu()
self.setCentralWidget(search)
So when you click the searchButton, it loads "loadingSearchWindow" which sets the searchMenu() as the CentralWidget.
And again, nothing happends when i click the toolButton that is supposed to load the search menu. And i dont know why, because im doing the same thing with the "buttons" function that loads the welcome menu without problems, but then it seems that if you want to add an other menu it doesn't work.
What am I doing wrong?