Asynchronously Updating Pygtk Tray Icon
Solution 1:
You can use gobject.timeout_add()
to add periodical tasks. The first parameter is the interval in seconds, the second parameter is the callback you want to be called. The callback is called as long as it returns something that evaluates to True
when used as a bool
.
See also section 20 of the PyGTK FAQ, in particular question 20.7.
Solution 2:
You can't refresh easily the tray icon , take it from some one that did already try this and failed (Actually i just drop it for the reason that "If the implementation is hard to explain, it's a bad idea.") ,
but here is what i have so far, to refresh the Status Icon you will have to set your status icon using gtk.status_icon_new_from_gicon()
method, from the doc :
Creates a status icon displaying a gio.Icon(). If the icon is a themed icon, it will be updated when the theme changes.
So if you want to refresh the Status Icon you will have to create your icon using gio themed icon , and now you can update directly your themed icon and this change will be shown directly in the tray status.
Now about your question :
Yes gtk.main() block waiting for signal, so you just have to bind a signal to an action and when this signal is triggered the action can be executed , for your case in your action callback you can put the code that will refresh your Status Image.
Hope i did help you here.
Post a Comment for "Asynchronously Updating Pygtk Tray Icon"