[Tkinter-discuss] Returning control from a toplevel window

Guido Carballo-Guerrero charras at me.com
Wed Apr 28 18:25:14 CEST 2010


 Micheal, but if I don't call the mainloop again inside of the toplevel window the pictures that I'm trying to display doesn't show up.

Guido

>
>Message: 2
>Date: Wed, 28 Apr 2010 09:59:35 +0200
>From: Michael Lange <klappnase at web.de>
>To: tkinter-discuss at python.org
>Subject: Re: [Tkinter-discuss] Returning control from a toplevel
>	window
>Message-ID: <20100428095935.b1603a90.klappnase at web.de>
>Content-Type: text/plain; charset=US-ASCII
>
>Hi,
>
>On Tue, 27 Apr 2010 15:44:39 -0700
>Guido Carballo-Guerrero <charras at me.com> wrote:
>
>> How can I get back into a while loop if I go to a new pop-up toplevel
>> window, that is created when I press one button.
>> 
>> I'm attaching a sample of the code that I'm trying to make. The
>> problem that I have is that after the button is press and the new
>> toplevel window, what ever is inside of the while loop doesn't do
>> anything anymore. Is as if I got out of the while loop.
>> 
>> Is there a way in which I can get back into the while loop once the
>> toplevel window is destroy?
>> 
>> Guido
>> 
>(...)
>> def new():
>>     root2 = Tkt.Toplevel()
>> 
>>     def ask_quit2():
>>         root2.destroy()
>>             
>>     root2.protocol("WM_DELETE_WINDOW", ask_quit2)
>> 
>>     L1 = ttk.Label(root2)
>>     L1.config(text = 'Window2')
>>     L1.pack()
>> 
>>     root2.mainloop()
>      ^^^^^^^^^^^^^^^^
>
>The second call to mainloop() is the problem, just remove it and
>everything will work as expected. mainloop() must only be called
>once per application (for the main Tk() window).
>
>I hope this helps
>
>Michael
>
>


More information about the Tkinter-discuss mailing list