[PyQt] Changing systray icon while handling signal
jbublitz at nwinternet.com
Fri Jan 18 07:09:36 GMT 2008
On Thursday 17 January 2008 21:26, Dog Walker wrote:
> 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
> 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).
You can call your application object's processEvents() method (see
QApplication docs) or maybe set other timers to do redraws.
More information about the PyQt