Newbie doing lengthy initialization with Tkinter gui

Maric Michaud maric at aristote.info
Sun Aug 13 07:45:02 EDT 2006


Le dimanche 13 août 2006 12:39, Pasi Oja-Nisula a écrit :

> The question is how (or where) can I call my loadImages function right
> after the mainloop starts? Or is there a better way to do this?
>
Seems a good use case for multi-thread, try something like this :

In [28]: import Tix

In [29]: main=Tix.Tk()

In [30]: p=Tix.Meter(main)

In [31]: p.pack()

In [32]: def process(progress) :
   ....:     from time import sleep
   ....:     for i in range(10) :
   ....:         sleep(1)
   ....:         p.configure(value=float(p.cget('value'))+0.1)
   ....:
   ....:


In [33]: import thread

In [34]: thread.start_new_thread(process, (p,)) and main.mainloop()

Of course the last line is tricky, the thread should be started by the 
App(Tix.Tk) mainloop.


> Pasi

-- 
_____________

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