There is a main window and you need to call its parent, while the main thing is to hide it. Then after some time, close the child and show the parent.

Now create it

Class constructor

self.root = Tk() self.main = MainWindow(self.root) self.main.StartServerEvent+=self.OnServerStart self.root.mainloop() 

Then when the event fires.

  self.root.destroy() self.root.quit() self.root = Tk() self.gameWindow = Game(self.root, self.server) self.root.mainloop() 

Up to this point it works, but now how to restore the first window?

  • Is this which you destroyed? - alexlz
  • Yes, which I destroyed how to recover? I just did not know how to hide it, so I destroyed it, and then I planned to just re-create it. - koks_rs
  • 2
    Or maybe it is not necessary to destroy it? Hide? self.root.withdraw () ... self.root.deiconify () - alexlz
  • Yes, perhaps it is possible. but is it a memory leak? - cyklop77

1 answer 1

In order to hide a window you need to use the method withdraw It hides the window without destroying it.

 self.root.withdraw() 

To make the hidden window then visible, use the deiconify method.

 self.root.deiconify() 

Read more about these methods here .