2017年10月10日 星期二

Tkinter 電子音樂-Button



from tkinter import *
import winsound
import time
C  = 262
Db = 277
D  = 294
Eb = 311
E  = 330
F  = 349
Gb = 370
G  = 392
Ab = 415
A  = 440
Bb = 466
B  = 494
hC  = 523
t = 250
root = Tk() # create tkinter window

def play_Do () :
    winsound.Beep(C, 2*t)
def play_Re () :
    winsound.Beep(D, 2*t)
def play_Mi () :
    winsound.Beep(E, 2*t)
def play_Fa () :
    winsound.Beep(F, 2*t)
def play_Sol () :
    winsound.Beep(G, 2*t)
def play_La () :
    winsound.Beep(A, 2*t)
def play_Si () :
    winsound.Beep(B, 2*t)
def play_Hi_Do () :
    winsound.Beep(hC, 2*t)

 
 
button1 = Button(root, text = 'Play_Do', command = play_Do)
button2 = Button(root, text = 'Play_Re', command = play_Re)
button3 = Button(root, text = 'Play_Mi', command = play_Mi)
button4 = Button(root, text = 'Play_Fa', command = play_Fa)
button5 = Button(root, text = 'Play_Sol', command = play_Sol)
button6 = Button(root, text = 'Play_La', command = play_La)
button7 = Button(root, text = 'Play_Si', command = play_Si)
button8 = Button(root, text = 'Play_Hi_do', command = play_Hi_Do)
button1.pack()
button2.pack()
button3.pack()
button4.pack()
button5.pack()
button6.pack()
button7.pack()
button8.pack()

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> &...