Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from PyQt4 import QtGui, QtCore
- class SystemTrayIcon(QtGui.QSystemTrayIcon):
- def __init__(self, icon, parent=None):
- QtGui.QSystemTrayIcon.__init__(self, icon, parent)
- menu = QtGui.QMenu(parent)
- exitAction = menu.addAction("Exit")
- helloAction = menu.addAction("Hello World")
- self.setContextMenu(menu)
- QtCore.QObject.connect(exitAction, QtCore.SIGNAL('triggered()'), self.exit)
- QtCore.QObject.connect(helloAction, QtCore.SIGNAL('triggered()'), self.hello)
- def exit(self):
- QtCore.QCoreApplication.exit()
- def hello(self):
- msg = QtGui.QMessageBox.information(QtGui.QMessageBox(), "Hello", "Hello World")
- def main():
- app = QtGui.QApplication(sys.argv)
- w = QtGui.QWidget()
- trayIcon = SystemTrayIcon(QtGui.QIcon("qtLogo.png"), w)
- trayIcon.show()
- sys.exit(app.exec_())
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement