Вопрос

I built an app with PyQt and cx_freeze that has a systray icon, however the icon does not show up in the system tray in Windows 7 (the app is there and running but just a blank spot - no icon). now it does work fine in windows XP on other computers, just not in win 7. any ideas?

Это было полезно?

Решение

icon = QtGui.QIcon('blah.png')
self.tray_icon = QtGui.QSystemTrayIcon(self)
self.tray_icon.setIcon(icon)
self.tray_icon.setVisible(True)
self.tray_icon.show()

this should work. however in win XP it looks like you only need "self.tray_icon.setIcon(icon)" and not ".setVisible(True)" or ".show()" for it to work which is the problem i was running in to. i also created a class inheriting QtGui.QApplication and added:

icon = QtGui.QIcon('blah.png')
self.setWindowIcon(icon)

unfortunately i dont know what of the above exactly solved the problem as i dont have a win 7 computer to personalty test things so i did the shotgun approach and it worked.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top