Created
August 2, 2017 18:17
-
-
Save AlexEshoo/754fd04a2771124a48f8c682f9b2a007 to your computer and use it in GitHub Desktop.
PyQt5 system tray program init
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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