In PyQt, is it any way to close the main window and open a new one?
In particular, I am trying to close a window and open the same window all over again. I've tried every way I could think of without success (with some resulting in segmentation fault). I need to do this because the new window will have some features according to the parameters that are passed.
How about this:
....
....
def selectMode( self ):
self.close()
self.field_params = params
self.show()
Well, somehow soon after posting I managed to make it work. Here is the code:
class GameWindow(QtGui.QMainWindow):
def __init__(self, field_params):
super(GameWindow, self).__init__()
self.field_params = field_params
#some code that ends up calling selectMode
def selectMode(self):
self.close()
self.__init__(params)
def main():
app = QtGui.QApplication(sys.argv)
game_window = GameWindow()
sys.exit(app.exec_())