python - How can I have an animated system tray icon in PyQt4? -
i trying create animated systray icon pyqt4 app having trouble finding examples in python. closest can find it's in c++ , don't know how translate over: is there way have (animated)gif image system tray icon pyqt?
how can go doing either animated gif or using series of still images frames?
maybe this. create qmovie instance used animatedsystemtrayicon. connect framechanged signal of movie , call seticon on qsystemtrayicon. need convert pixmap returned qmovie.currentpixmap qicon pass seticon.
disclaimer, tested on linux.
import sys pyqt4 import qtgui class animatedsystemtrayicon(qtgui.qsystemtrayicon): def updateicon(self): icon = qtgui.qicon() icon.addpixmap(self.iconmovie.currentpixmap()) self.seticon(icon) def __init__(self, movie, parent=none): super(animatedsystemtrayicon, self).__init__(parent) menu = qtgui.qmenu(parent) exitaction = menu.addaction("exit") self.setcontextmenu(menu) self.iconmovie = movie self.iconmovie.start() self.iconmovie.framechanged.connect(self.updateicon) def main(): app = qtgui.qapplication(sys.argv) w = qtgui.qwidget() trayicon = animatedsystemtrayicon(movie=qtgui.qmovie("cat.gif"), parent=w) w.resize(250, 150) w.move(300, 300) w.setwindowtitle('anim systray') w.show() trayicon.show() sys.exit(app.exec_()) if __name__ == '__main__': main()
Comments
Post a Comment