Skip to content

Commit 5000db4

Browse files
authored
Merge pull request #919 from rohanprichard/main
Fixed the issue of pomodoro timer not running on mac because of winsound
2 parents 1246d88 + 017615b commit 5000db4

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

pomodoro_timer/pomodoro_timer.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
from tkinter.constants import BOTTOM, FLAT, LEFT
55
from tkinter.font import BOLD
66
import threading
7-
import winsound
7+
import os
88

9-
ctypes.windll.shcore.SetProcessDpiAwareness(True)
9+
try:
10+
import winsound
11+
ctypes.windll.shcore.SetProcessDpiAwareness(True)
12+
except Exception:
13+
pass
1014

1115
root = Tk()
1216
root.config(bg="Salmon")
@@ -68,17 +72,24 @@ def start_timer(options, cycle_limit=5):
6872
root.update_idletasks()
6973
time.sleep(1)
7074
temp_work -= 1
71-
winsound.Beep(323, 250)
72-
winsound.Beep(583, 250)
75+
try:
76+
winsound.Beep(323, 250)
77+
winsound.Beep(583, 250)
78+
except Exception:
79+
os.system('tput bel')
80+
7381
while temp_break:
7482
title_label.config(text="You should be taking a break now.")
7583
minutes, seconds = divmod(temp_break, 60)
7684
timer_label.config(text=f"{minutes}:{seconds}")
7785
root.update_idletasks()
7886
time.sleep(1)
7987
temp_break -= 1
80-
winsound.Beep(523, 250)
81-
winsound.Beep(783, 250)
88+
try:
89+
winsound.Beep(523, 250)
90+
winsound.Beep(783, 250)
91+
except Exception:
92+
os.system('tput bel')
8293
cycles += 1
8394

8495
reset()

0 commit comments

Comments
 (0)