#Example code that shows a way to switch between two windows, #having only one of the visible (active) at a time. # The key is the window.withdraw() call (to hide) # and the window.deiconify() to make it appear again. from tkinter import * class WinDos: def __init__(self,mainWin): self.mainWin = mainWin Label(self.mainWin, text="Main Window").pack() b1 = Button(self.mainWin, text="switch to 2nd window", command=self.win2up) b1.pack() self.secondWin = Toplevel() Label(self.secondWin, text="SecondWin").pack() b2 = Button(self.secondWin, text="Switch to first window!", command=self.win1up) b2.pack() self.secondWin.withdraw() # Hide this window until we need it! self.secondWin.protocol("WM_DELETE_WINDOW", self.endProgram) def endProgram(self): print("end program called!") self.mainWin.destroy() def win1up(self): print("Switching to window 1!") self.secondWin.withdraw() self.mainWin.deiconify() def win2up(self): print("Switching to window 2!") self.mainWin.withdraw() self.secondWin.deiconify() mw = Tk() myApp = WinDos(mw) mw.mainloop() print("All done!")