[PyQt] Changing systray icon while handling signal

Dog Walker thudfoo at gmail.com
Fri Jan 18 05:26:56 GMT 2008


On Jan 17, 2008 2:23 PM, Jim Bublitz <jbublitz at nwinternet.com> wrote:
> On Thursday 17 January 2008 08:27, Dog Walker wrote:
> > Using pyKde3
> >
> > I have a KSytemTray application. I want to change the systray icon
> > (and tooltip)  when I begin handling a menuitem and change again
> > before returning. It appears that the icon/tooltip is only set after
> > returning to pyKde. Can I do what I want? How?
>
> Assuming you're using KSystemTray, KSystemTray.setPixmap (pix) sets the icon
> to "pix", whatever it's value is when called.
>
> See PyKDE/examples/systray.py
>
> Jim
>
[...]

I have failed to make myself clear.

I have an icon in the systray with a menu.
One of the the menuitems is do_time_consuming_task.
When that menu item is selected by the user, function
do_time_consuming_task() runs.
That function tries to set the systray icon to busybusy.png and set
the tooltip to "TCB'ing".
Immediatley after doing the icon change and tooltip code, the function
begins a long task.
After the long task end, the function changes the systray icon and
tooltip text back to what it was.
The function returns.

The icon/tooltip does not change during the running of the function.
Neither is the icon in the systray repainted if covered or when switching
desktops.
-------------------------------------------------
Anyway I solved the icon change part. The long running function could
be invoked from the menu or by a timer interrupt. So the first time
the long running function is entered, the icon is changed and a short
timer is set to invoke the function. The function returns, is
reentered, it does its long running thing, sets another icon and
restores the normal timer interval. Setting a tooltip to show during
the long running function is worthless because the app loop must be
running to show it. For the same reason, the icon disappears in the
systray if the user switches desktops (all the systray icons are
erased and must be repainted).

-- 
I have seen the future and I'm not in it!


More information about the PyQt mailing list