Skip to content Skip to sidebar Skip to footer

Pygtk's Strange Problem About Set Button's Sensitive Property

on one of my methods, I have the following code: def fun(): self.button1.set_sensitive(False) self.get_time() However, self.button1 only becomes insensitive after get_time()

Solution 1:

I think programmic changes to widgets applies in the next lap of event loop (gtk.main()), that is probably after finishing fun function. Does that make a problem for you? How much time self.get_time() takes? If that takes a sensible time, you can update widgets before that:

def fun():
   self.button1.set_sensitive(False)
   while gtk.events_pending():
       gtk.main_iteration_do(False)
   self.get_time()

Solution 2:

Uhh are you sure you want to do that? All GUI programming events are done by message passing and so you really shouldn't block the main thread for long enough you'd ever need some workaround like this. And if you do that, you'll soon have other problems like the window manager killing your window because it's not responding to ping or reentrance problems when you do the iteration. If you have some complicated task like burning a CD or whatever that takes that long, put the actual burning into its own executable and call it by glib.spawn_async (or similar). Use gobject.child_watch_add to ask to be notified about termination.


Post a Comment for "Pygtk's Strange Problem About Set Button's Sensitive Property"