I have a long, computationally intensive task that I want to use a
progress bar for.

My problem is that the progress bar is only displaying at the end of
the computation, even though the function updating the progress bar is
being called during the long computation

        dlg = gtk.Dialog('Computing coherences', flags=gtk.DIALOG_MODAL)
        dlg.set_transient_for(parent)
        dlg.show()
    
        progBar = gtk.ProgressBar()
        progBar.set_text('Almost there...')
        progBar.set_usize(300, 40)
        progBar.set_fraction(0)
        progBar.show()
        dlg.vbox.pack_start(progBar)
        def progress_callback(frac,  msg):
            print msg, frac
            progBar.set_text(msg)
            progBar.set_fraction(frac)

        somelongcomputation(pars, progress_callback)

somelongcomputation periodically calls progress_callback with a
fraction and a message.

I am printing the results to stdout just to make sure that the
progress_callback is being called, and it is.  Only the bar is not
updating.

Is this some kind of resource sharing problem, ie, the progress
bar doesn't update itself under a heavy CPU load?

In my search of the archives, I've seen some references to 

        while gtk.events_pending():
            gtk.mainiteration()

but am not sure if this is relevant here.

Any suggestions?

Thanks,
John Hunter

pygtk 1.99.14
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to