Skip to content

Commit 6b9bbfe

Browse files
committed
Fixed the issue of pomodoro timer not running on mac because of winsound
1 parent 1246d88 commit 6b9bbfe

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

pomodoro_timer/pomodoro_timer.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
from tkinter.constants import BOTTOM, FLAT, LEFT
55
from tkinter.font import BOLD
66
import threading
7-
import winsound
7+
import os
8+
9+
try:
10+
import winsound
11+
ctypes.windll.shcore.SetProcessDpiAwareness(True)
12+
except:
13+
pass
814

9-
ctypes.windll.shcore.SetProcessDpiAwareness(True)
1015

1116
root = Tk()
1217
root.config(bg="Salmon")
@@ -68,17 +73,27 @@ def start_timer(options, cycle_limit=5):
6873
root.update_idletasks()
6974
time.sleep(1)
7075
temp_work -= 1
71-
winsound.Beep(323, 250)
72-
winsound.Beep(583, 250)
76+
77+
try:
78+
winsound.Beep(323, 250)
79+
winsound.Beep(583, 250)
80+
except:
81+
os.system('beep -f %s -l %s' % (323,250))
82+
os.system('beep -f %s -l %s' % (583,250))
83+
7384
while temp_break:
7485
title_label.config(text="You should be taking a break now.")
7586
minutes, seconds = divmod(temp_break, 60)
7687
timer_label.config(text=f"{minutes}:{seconds}")
7788
root.update_idletasks()
7889
time.sleep(1)
7990
temp_break -= 1
80-
winsound.Beep(523, 250)
81-
winsound.Beep(783, 250)
91+
try:
92+
winsound.Beep(523, 250)
93+
winsound.Beep(783, 250)
94+
except:
95+
os.system('beep -f %s -l %s' % (323,250))
96+
os.system('beep -f %s -l %s' % (583,250))
8297
cycles += 1
8398

8499
reset()

0 commit comments

Comments
 (0)