Re: GUI freeze and long blocking operation



On 12 June 2013 01:52, Kip Warner <kip thevertigo com> wrote:
My GtkAssistant on one page in particular performs a long operation
which would otherwise block the GUI from refreshing, if it were not for
intermittent...

        while Gtk.events_pending():
            Gtk.main_iteration()

To start the long work, the "prepare" signal is captured in my
assistant and the long job ("startDiscVerification()") method is
enqueued via GObject.idle_add() in the onPrepare() method.

Do you need to use idle_add()?

I have a Progress class I use to draw a progress bar on the screen and
show a spinner and all that. It does the while pending / iterate thing
too. My code looks something like:

init:
  photo = gtk.Button('RTI Capture ...')
  photo.connect('clicked', self.rti_capture_cb, None)

rti_capture_cb:
  mark gui insensitive
  enable progress feedback

  while long_job():
    do a bit of work
    self.progress.update(percent)

  hide progress feedback
  mark gui active again

Code here, if it's any help:

https://github.com/jcupitt/rtiacquire

John


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]