Initial working tray util

This commit is contained in:
Alexander Hosking 2020-12-24 16:00:54 -05:00
commit 9898cc1a82
3 changed files with 52 additions and 0 deletions

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

44
system_tray.py Normal file
View 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
View File

@ -0,0 +1,8 @@
{
"folders": [
{
"path": "."
}
],
"settings": {}
}