1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| from tkinter import*
import winsound
liste=[523,587,639,698,784,880,988,1046]
def note(i):
frequence=liste[i]
winsound.Beep(frequence,500)
def touche1():
note(0)
def touche2():
note(1)
def touche3():
note(2)
def touche4():
note(3)
def touche5():
note(4)
def touche6():
note(5)
def touche7():
note(6)
def touche8():
note(7)
def pointeur(evt):
if evt.char=='a':
note(0)
elif evt.char=='z':
note(1)
elif evt.char=='e':
note(2)
elif evt.char=='r':
note(3)
elif evt.char=='t':
note(4)
elif evt.char=='y':
note(5)
elif evt.char=='u':
note(6)
elif evt.char=='i':
note(7)
fen1= Tk()
bou11= Button(fen1,bg="white",height=40,width=18,activebackground='purple',command=touche1)
bou11.grid(row=0,column=0)
bou12= Button(fen1,bg="white",height=40,width=18,activebackground='pink',command=touche2)
bou12.grid(row=0,column=1)
bou13= Button(fen1,bg="white",height=40,width=18,activebackground='red',command=touche3)
bou13.grid(row=0,column=2)
bou14= Button(fen1,bg="white",height=40,width=18,activebackground='orange',command=touche4)
bou14.grid(row=0,column=3)
bou15= Button(fen1,bg="white",height=40,width=18,activebackground='yellow',command=touche5)
bou15.grid(row=0,column=4)
bou16= Button(fen1,bg="white",height=40,width=18,activebackground='green',command=touche6)
bou16.grid(row=0,column=5)
bou17= Button(fen1,bg="white",height=40,width=18,activebackground='cyan',command=touche7)
bou17.grid(row=0,column=6)
bou18= Button(fen1,bg="white",height=40,width=18,activebackground='blue',command=touche8)
bou18.grid(row=0,column=7)
fen1.bind('a', pointeur)
fen1.bind('z', pointeur)
fen1.bind('e', pointeur)
fen1.bind('r', pointeur)
fen1.bind('t', pointeur)
fen1.bind('y', pointeur)
fen1.bind('u', pointeur)
fen1.bind('i', pointeur)
fen1.mainloop() |
Partager