有没有办法将(动画)GIF 图像作为 pyqt 的系统托盘图标? [英] Is there a way to have (animated)GIF image as system tray icon with pyqt?
本文介绍了有没有办法将(动画)GIF 图像作为 pyqt 的系统托盘图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 pyqt 创建了静态(PNG)图像作为托盘图标.
I have created static(PNG) image as tray icon with pyqt.
对 GIF 图像执行相同的操作会导致静态托盘图标.可以用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"))
推荐答案
使用 QMovie
播放动画 gif,并在每个新的帧事件上更新托盘图标:
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());
}
对于 C++ 示例,抱歉,我没有安装 PyQt.
Sorry for the C++ example, I don't have PyQt installed.
这篇关于有没有办法将(动画)GIF 图像作为 pyqt 的系统托盘图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文