|
4 | 4 | from tkinter.constants import BOTTOM, FLAT, LEFT
|
5 | 5 | from tkinter.font import BOLD
|
6 | 6 | import threading
|
7 |
| -import winsound |
| 7 | +import os |
| 8 | + |
| 9 | +try: |
| 10 | + import winsound |
| 11 | + ctypes.windll.shcore.SetProcessDpiAwareness(True) |
| 12 | +except: |
| 13 | + pass |
8 | 14 |
|
9 |
| -ctypes.windll.shcore.SetProcessDpiAwareness(True) |
10 | 15 |
|
11 | 16 | root = Tk()
|
12 | 17 | root.config(bg="Salmon")
|
@@ -68,17 +73,27 @@ def start_timer(options, cycle_limit=5):
|
68 | 73 | root.update_idletasks()
|
69 | 74 | time.sleep(1)
|
70 | 75 | 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 | + |
73 | 84 | while temp_break:
|
74 | 85 | title_label.config(text="You should be taking a break now.")
|
75 | 86 | minutes, seconds = divmod(temp_break, 60)
|
76 | 87 | timer_label.config(text=f"{minutes}:{seconds}")
|
77 | 88 | root.update_idletasks()
|
78 | 89 | time.sleep(1)
|
79 | 90 | 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)) |
82 | 97 | cycles += 1
|
83 | 98 |
|
84 | 99 | reset()
|
|
0 commit comments