3
I’m still a beginner in Pyqt and would like to clarify a question:
Is there any way to define a Tray Icon (Tray Icon) in a Pyqt application? If so, how can I do it?
I need to set some options on this tray icon. There are ways to do this too?
3
I’m still a beginner in Pyqt and would like to clarify a question:
Is there any way to define a Tray Icon (Tray Icon) in a Pyqt application? If so, how can I do it?
I need to set some options on this tray icon. There are ways to do this too?
3
The class QSystemTrayIcon
serves this purpose.
Assuming your application is qApp
, here’s a small example:
trayIcon = QtGui.QSystemTrayIcon( QtGui.QIcon('icone.png' ), qApp)
trayIcon.setTooltip('eu sou um ícone de bandeja')
sair = menu.addAction("Sair")
menu = QtGui.QMenu()
trayIcon.setContextMenu(menu)
trayIcon.show()
Points of interest:
setTooltip
serves to set the "hint" that appears, for example when you hover over the icon;
setContextMenu
, as the name says, serves to add a context menu to the icon. See the documentation for QMenu
for more details;
If you want to animate the icon, you can make calls to the method setIcon(const QIcon & icon)
, using a QTimer
, for example. It is only advisable not to want to do anything too complex, not to sacrifice the responsiveness of OS.
Still, it is worth noting that there is the method showMessage
, if you want to display a message to the user. For example, in Windows 7, a balloon is used:
Browser other questions tagged python python-2.7 pyqt pyqt-4
You are not signed in. Login or sign up in order to post.