On Sat, 2005-03-26 at 12:17 +0100, L�szl� Monda wrote:
> Dear PyGTK folks,
>
> I want to make my application very responsive under high load. I've
> written a simple test application to demonstrate my problem in a clear
> way.
>
> I attached the related code, but including here for easier discussion:
>
> import gtk
> import threading
>
> def do_heavy_stuff():
> for i in range(1, 100):
> print `i+1` + '%'
> k = 0
> for j in range (1, 100000):
> k += 1
>
> def timerfunc(crap):
> if not thread.isAlive():
> window.remove(pbar)
> window.add(label)
> window.show_all()
> pbar.pulse()
> return thread.isAlive()
>
> def destroy_handler(window):
> gtk.main_quit()
>
> window = gtk.Window(gtk.WINDOW_TOPLEVEL)
> pbar = gtk.ProgressBar()
> label = gtk.Label('Ready.')
>
> window.connect('destroy', destroy_handler)
> window.add(pbar)
> window.set_default_size(200, 20)
> window.show_all()
>
> timer = gtk.timeout_add(100, timerfunc, pbar)
> thread = threading.Thread(target=do_heavy_stuff)
> thread.start()
>
> gtk.main()
>
> As you can see, I want to pulse a progress bar while a long
> (computationally or I/O intensive) operation is running. I started a
> separate thread for it.
>
> I would expect this application to run do_heavy_stuff smoothly while
> pulsing the progress bar simultaneously, but actually while the progress
> bar is pulsing, nothing really happens. Only after colsing the window,
> do_heavy_stuff begins to run.
>
> So what could be wrong here?
I'm not really sure, but try calling gtk.threads_init() after
importing gtk module. It might help...
>
> Thank you very much in advance!
>
> PS: I post this message to the list for the second time. The first time
> when I posted I wasn't registered on the list and I've been waiting for
> the approval for 3 weeks. I know resending is a bad policy, but I
> cannot wait forever.
I don't think jamesh has time to moderate the pygtk list, I'm afraid.
You have to be subscribed before posting, or wait forever...
Regards.
--
Gustavo J. A. M. Carneiro
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
The universe is always one step beyond logic
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/