From 9987c842bb2cb3d95eafde7d079ef6adbf3a55a3 Mon Sep 17 00:00:00 2001 From: Andrei Stoica Date: Sun, 2 Feb 2020 14:29:57 -0500 Subject: [PATCH] fixed logic for loading icons --- src/pomodoro-desktop.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/pomodoro-desktop.py b/src/pomodoro-desktop.py index c73188f..549c9e4 100644 --- a/src/pomodoro-desktop.py +++ b/src/pomodoro-desktop.py @@ -26,6 +26,11 @@ else: with open(config_file) as f: config.read_file(f) +icons = {icon : path.join(sys.path[0], '../icons', icon + '.png') + for icon in ['Go', 'Wait', 'Stop']} + +print(icons) + pomo_time = config.getint('DEFAULT','pomo_time') break_time = config.getint('DEFAULT','break_time') long_break = config.getint('DEFAULT','long_break') @@ -45,7 +50,7 @@ def end_pomo(): global started, counter counter+=1 started = False - tray.setIcon(QIcon("icons/Stop.png")) + tray.setIcon(QIcon(icons['Stop'])) if counter % long_break == 0: notify(f"Take a break for {long_break_time} minutes.", title='LONG BREAK') @@ -56,7 +61,7 @@ def end_pomo(): sleep(break_time * 60) if not started: - tray.setIcon(QIcon("icons/Wait.png")) + tray.setIcon(QIcon(icons['Wait'])) notify("You should probably get back to work") def start(): @@ -64,7 +69,7 @@ def start(): if not started: if pomo_timer: pomo_timer.cancel() - tray.setIcon(QIcon("icons/Go.png")) + tray.setIcon(QIcon(icons['Go'])) started = True notify(f"You got {pomo_time} minutes to work.", title='WORK') pomo_timer = threading.Timer(pomo_time * 60, end_pomo) @@ -76,7 +81,7 @@ def stop_work(): global pomo_timer, started if pomo_timer: started = False - tray.setIcon(QIcon("icons/Wait.png")) + tray.setIcon(QIcon(icons['Wait'])) pomo_timer.cancel() if started: notify("Alright take your unscheduled break...") @@ -88,7 +93,7 @@ def quit(): # Create the icon -icon = QIcon("icons/Wait.png") +icon = QIcon(icons['Wait']) # Create the tray tray = QSystemTrayIcon()