Tkinter question

eb303 eric.brunel.pragmadev at gmail.com
Fri Apr 23 09:46:37 CEST 2010


On Apr 22, 5:55 pm, Rotwang <sg... at hotmail.co.uk> wrote:
> James Mills wrote:
> > On Wed, Apr 21, 2010 at 8:45 PM, Rotwang <sg... at hotmail.co.uk> wrote:
>
> >> [...]
>
> >>From reading the documentation myself (pydoc)...
>
> > It would seem your only option is to make a thread
> > out of this (not my preferred way - I was hoping it was
> > possible to poll the Tk event system...).
>
> Thanks, I don't know anything about threading at the moment but I'll
> look into it.

>From my experience, mixing Tkinter with threads is a bad idea. As most
GUI toolkits, it really doesn't like to be manipulated from different
threads, so you might end up getting weird problems or even crashes.

By the way, did you try to remove the line out.mainloop() from your
'draw' function? This is the line that blocks the IDLE GUI, since it
initiates a secondary event loop that will only exit when you do a
out.quit(), so that might be a solution.

> BTW, another problem: whenever I call a widget.quit() method, the widget
> in question crashes. IDLE carries on working but the widget window stays
> there, not responding, and if I tell my OS to kill it then IDLE
> restarts. Is this a bug? I'm using Windows 7 and Python 2.6.4.

The 'quit' method just exits the mainloop. It doesn't destroy the
widget. So if your application doesn't actually exit, the widget will
just stay there. If you want to destroy the it too, you have to call
explicitely widget.destroy().

HTH
 - Eric -



More information about the Python-list mailing list