Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Python by Nazym ( 6 years ago )
def play_note(note, btn):
    canv.itemconfig(btn_do, fil='white')
    canv.itemconfig(btn_re, fil='white')
    canv.itemconfig(btn_mi, fil='white')
    canv.itemconfig(btn_fa, fil='white')
    canv.itemconfig(btn_sol, fil='white')
    canv.itemconfig(btn_la, fil='white')
    canv.itemconfig(btn_si, fil='white')
    canv.itemconfig(btn_do2, fil='white')

    if flag==1:
        file_name="notes/1/"+note+".wav"
    elif flag==2:
        file_name="notes/2/"+note+".wav"
    elif  flag==3:
        file_name="notes/3/"+note+".wav"
    elif  flag==4:
        file_name="notes/4/"+note+".wav"

    winsound.PlaySound(file_name, winsound.SND_FILENAME)
    canv.itemconfig(btn, fil='yellow')

def key_handl(event):
    global flag

    if event.keysym=="z":
        play_note('do', btn_do)
    elif event.keysym=="x":
        play_note('re', btn_re)
    elif event.keysym=="c":
        play_note('mi', btn_mi)
    elif event.keysym=="v":
        play_note('fa', btn_fa)
    elif event.keysym=="b":
        play_note('sol', btn_sol)
    elif event.keysym=="n":
        play_note('la', btn_la)
    elif event.keysym=="m":
        play_note('si', btn_si)
    elif event.keysym=="q":
        play_note('do2', btn_do2)
    elif event.keysym=="1":
        flag=1
    elif event.keysym=="2":
        flag=2
    elif  event.keysym=="3":
        flag=3
    elif  event.keysym=="4":
        flag=4

canv.bind("<KeyPress>", key_handl)
canv.focus_set()

 

Revise this Paste

Your Name: Code Language: