commit 9898cc1a82fc0b77067f1a1b84096e745dbf3177 Author: Alexander Hosking Date: Thu Dec 24 16:00:54 2020 -0500 Initial working tray util diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..40313a8 Binary files /dev/null and b/icon.png differ diff --git a/system_tray.py b/system_tray.py new file mode 100644 index 0000000..67bd798 --- /dev/null +++ b/system_tray.py @@ -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() \ No newline at end of file diff --git a/workspace.code-workspace b/workspace.code-workspace new file mode 100644 index 0000000..876a149 --- /dev/null +++ b/workspace.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} \ No newline at end of file