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

3.1k Views Asked by At

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

Did the same with GIF image results in static tray icon. Can it animated in system tray with pyqt?

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

There are 1 best solutions below

0
On

Use QMovie to play the animated gif, and update the tray icon on each 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 installed.