Skip to content

Instantly share code, notes, and snippets.

@AlexEshoo
Created August 2, 2017 18:17
Show Gist options
  • Save AlexEshoo/754fd04a2771124a48f8c682f9b2a007 to your computer and use it in GitHub Desktop.
Save AlexEshoo/754fd04a2771124a48f8c682f9b2a007 to your computer and use it in GitHub Desktop.
PyQt5 system tray program init
import sys
from PyQt5 import QtWidgets, QtGui
class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
def __init__(self, icon, parent=None):
QtWidgets.QSystemTrayIcon.__init__(self, icon, parent)
menu = QtWidgets.QMenu(parent)
exitAction = menu.addAction("Exit")
self.setContextMenu(menu)
def main():
app = QtWidgets.QApplication(sys.argv)
w = QtWidgets.QWidget()
trayIcon = SystemTrayIcon(QtGui.QIcon("Bomb.xpm"), w)
trayIcon.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment