2017年10月10日 星期二

Tkinter Python Song of Time

from tkinter import *
import time
import platform
try:
    import winsound
    beep = winsound.Beep
except ImportError:
    def beep(f, d):
        s = 8000
        hp = int(s/f/2)
        b = chr(255)*hp+chr(0)*hp
        b *= int(d*f)
        a = file('/dev/audio', 'wb')
        a.write(b)
        a.close()   
root = Tk() # create tkinter window

c = [
(880, 700),
(587, 1000),
(698, 500),
(880, 500),
(587, 1000),
(698, 500),
(880, 250),
(1046, 250),
(988, 500),
(784, 500),
(699, 230),
(784, 250),
(880, 500),
(587, 500),
(523, 250),
(659, 250),
(587, 750)
]

s = c + c

for f, d in s:
beep(f, d)

root.mainloop()

沒有留言:

張貼留言

2024年4月24日 星期三 Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --2

 2024年4月24日 星期三 Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --2 AngularJS 實例 <!DOCTYPE html> <html> <head> &...