[Tkinter-discuss] Returning control from a toplevel

Michael Lange klappnase at web.de
Wed Apr 28 20:32:23 CEST 2010


On Wed, 28 Apr 2010 09:38:52 -0700
Guido Carballo-Guerrero <charras at me.com> wrote:

> Michael;
> What I did to solve the problem, was put the while loop inside of a
> function, so when I'm exiting the toplevel windows, I call that
> function, in that way I get back into the while loop. Is there a
> problem with this? What is the problem of calling the mainloop in the
> various windows? Why I can't display the pictures unless I call the
> mainloop inside of the toplevel windows? What happens when I call the
> mainloop inside of the toplevel windows, that kick me out of the
> while loop? Cause you're right, when I don't call mainloop inside of
> the new toplevel window, everything keeps running in the main program
> as if anything had happen.

That's a lot of questions :)
Maybe one of the gurus here can explain better than me why exactly
there must not be more than one mainloop. I think the problem with your
stopped while loop happens because the mainloop() does not return until
the main application window is destroyed. You can verify this by adding
a "print" statement after the second mainloop() to the new() function
in your previous example.
If you are not able to display images in the Toplevel window there is
surely something else wrong with your code, so maybe you can post a
short code example that shows this problem? It should definitely be
possible to put images in a Toplevel without a second mainloop :)



More information about the Tkinter-discuss mailing list