Is there a way to have a (animated) GIF as a system tray icon with pyqt?

I created a static image (PNG) as a tray icon with pyqt.

Ditto with a GIF image results in a static tray icon. Can it animate in the system tray with pyqt?

QtGui.QSystemTrayIcon.__init__(self, parent)
self.setIcon(QtGui.QIcon("Image.gif"))

      

+2


source to share


1 answer


Use QMovie

to play an animated gif and update the tray icon on every new frame event:

m_icon = new QSystemTrayIcon();
m_icon->show();
m_gif = new QMovie(":/animated.gif");
connect(m_gif, SIGNAL(frameChanged(int)), this, SLOT(updateIcon()));
m_gif->start();

      

...



void MyWidget::updateIcon()
{
    m_icon->setIcon(m_gif->currentPixmap());
}

      

Sorry for the C ++ example, I don't have PyQt.

+3


source







All Articles