Skip to content

Commit 3d0828c

Browse files
authored
Add files via upload
1 parent ccfb6db commit 3d0828c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

WinSoundTest.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import os
2+
import tkinter as tk
3+
import winsound
4+
import PeriodicTkAfter
5+
6+
7+
8+
if __name__ == '__main__':
9+
class App:
10+
11+
def __init__(self):
12+
self.periodic_time = PeriodicTkAfter.PeriodicTkAfter(1000) # Timer.
13+
self.cnt = 0
14+
15+
self.root = tk.Tk()
16+
self.root.title(os.path.basename(__file__))
17+
18+
winsound.SND_ASYNC = True
19+
20+
tk.Button(self.root, text="500", command=lambda: winsound.Beep(500, 1000), width=10, height=1).grid(row=0, column=0, sticky='w')
21+
tk.Button(self.root, text="1000", command=lambda: winsound.Beep(1000, 1000), width=10).grid(row=1, column=0, sticky='w')
22+
tk.Button(self.root, text="2000", command=lambda: winsound.Beep(frequency=2000, duration=2000), width=10).grid(row=2, column=0,
23+
sticky='w')
24+
25+
self.update()
26+
self.root.mainloop()
27+
28+
def update(self):
29+
self.root.after(self.periodic_time.get_next_delta_ms(), self.update)
30+
print(self.cnt)
31+
self.cnt += 1
32+
33+
app = App()

0 commit comments

Comments
 (0)