Initial working tray util
This commit is contained in:
commit
9898cc1a82
44
system_tray.py
Normal file
44
system_tray.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from PySide2 import QtWidgets, QtGui
|
||||||
|
|
||||||
|
class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
|
||||||
|
"""
|
||||||
|
Create the system Tray
|
||||||
|
"""
|
||||||
|
def __init__(self, icon, parent=None):
|
||||||
|
QtWidgets.QSystemTrayIcon.__init__(self, icon, parent)
|
||||||
|
self.setToolTip(f'Alex And His Backup Utility')
|
||||||
|
menu = QtWidgets.QMenu(parent)
|
||||||
|
|
||||||
|
backup_files = menu.addAction("Backup Bookmarks")
|
||||||
|
backup_files.triggered.connect(self.copy_files)
|
||||||
|
backup_files.setIcon(QtGui.QIcon("icon.png"))
|
||||||
|
menu.addSeparator()
|
||||||
|
|
||||||
|
exit_ = menu.addAction("Exit")
|
||||||
|
exit_.triggered.connect(lambda: sys.exit())
|
||||||
|
|
||||||
|
self.setContextMenu(menu)
|
||||||
|
self.activated.connect(self.onTrayIconActivated)
|
||||||
|
|
||||||
|
def onTrayIconActivated(self, reason):
|
||||||
|
if reason == self.DoubleClick:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def copy_files(self):
|
||||||
|
os.system('notepad')
|
||||||
|
|
||||||
|
def main():
|
||||||
|
app = QtWidgets.QApplication(sys.argv)
|
||||||
|
w = QtWidgets.QWidget()
|
||||||
|
tray_icon = SystemTrayIcon(QtGui.QIcon("icon.png"), w)
|
||||||
|
tray_icon.show()
|
||||||
|
tray_icon.showMessage('Bookmarks Backup Utility', 'Hi!')
|
||||||
|
sys.exit(app.exec_())
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
8
workspace.code-workspace
Normal file
8
workspace.code-workspace
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user