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

蹲街弑〆低调 提交于 2019-12-21 06:15:16

问题


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:


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.



来源:https://stackoverflow.com/questions/4816445/is-there-a-way-to-have-animatedgif-image-as-system-tray-icon-with-pyqt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!