Reputation: 1077
It's said that you should not call GUI functions from a thread, but I'm wondering if this is applicable only when you call functions which affects GUI directly or it's applicable on every function provided by GUI library. By example, it is safe to call:
gobject.idle_add(self.gui.get_object('button1').set_sensitive, False)
in a thread? Because self.gui.get_object is a function from the GUI framework but self.gui.get_object('button1') is actually calling it.
Thank you for your answers.
Upvotes: 4
Views: 173
Reputation: 416
The call you showed there seems safe. As already posted, you can read (get_object
) just fine in any thread, but should only modify (set_sensitive
) in the main thread. Exactly this is done here, idle_add
adds the event to the main loop which is running in the main thread.
Upvotes: 1
Reputation: 5540
Threading with GUI is bit tricky.If you want to do it right, you should not update GUI from within any other thread than main thread (common limitation in GUI libs). However you can make multiple read calls from several threads.
Upvotes: 0