I have an already large Tkinter
program, so that I have an init file, where the root = Tk()
window is defined (containing basically a Text
widget and a few other things), some more code, and last the call to mainloop()
function.
Everything works, until I needed to call a procedure before the mainloop
, and I wanted to raise a wait
window at the begin, to be destroyed at procedure's end.
I wrote something like:
msg = Message(root, text='wait a few seconds...')
msg.pack()
But it doesn't and cannot work, since mainloop()
has not been called yet!
If I instead do:
msg = Message(root, text='wait a few seconds...')
msg.pack()
mainloop()
The program stops at this first mainloop
, doesn't finish the procedure call.
mainloop()
should be used as your last program line, after which the Tkinter program works by a logic driven by user clicks and interactions, etc.
Here, I need a sequence of raise window > do stuff > destroy window > mainloop