I am trying to make a tkinter application which doesn't close everything (other windows) when the first window (root) is closed. I have tried to use Toplevel()
which works perfectly for pop-up windows in other programs but not for making a base level.
from tkinter import *
top = Toplevel(bg='red')
top.mainloop()
I don't know if this is possible or I don't know if I can change the Tk()
's properties to make it so it doesn't shut all other windows down.
There are two windows getting displayed because when a tkinter widget is created, it forces a
Tk
instance to be created as well, and every widget, unless a parent is explicitly passed, is a child to that automatically createdTk
instance. So your code essentially mimics the following code:Now there are some ways to work around that for the behavior you want, one is to hide the actual
Tk
instance:Another way would be to overrule the deletion of the
root
itself, but I doubt that's actually what you want: