Newbie doing lengthy initialization with Tkinter gui
Maric Michaud
maric at aristote.info
Mon Aug 14 04:40:51 EDT 2006
Le dimanche 13 août 2006 16:01, jmdeschamps at gmail.com a écrit :
> No neep for thread or Tix modules...!
Module thread is always available (at less on platforms where Tkinter is
available), while Tix in my example is just intended to use the Meter widget
(a progress bar).
> # this will *sleep* one millisec before calling
> # your doInitOne function and continue
> # with the rest of the code during that sleep time
> # in this case just the mainloop
> root.after(1, doInitOne)
> root.mainloop()
hum, this has not exactly the same effect, after, after_cancel, etc. are for
scheduling actions in the future, and when the action start, it will block
the mainloop and user interaction (this is why you need to call explicitly
the update method), so the gui will not respond anymore.
Finally why do you differ the call of your function after the mainloop since
it will block ?
That's said, I remember now that there isn't anything in Tkinter (no events
or callbacks) to get the 'mainloop started' hook, so you must start the
thread before the mainloop, probably like this :
class myApp(Toplevel) :
def mainloop(self) :
start_new_thread(initFunc, params)
Toplevel.mainloop(self)
--
_____________
Maric Michaud
_____________
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
More information about the Python-list
mailing list