Skip to content

Instantly share code, notes, and snippets.

@HuangJiaLian
Created March 31, 2022 15:31
Show Gist options
  • Save HuangJiaLian/722a284329ea0f2179c6291ca2032b6d to your computer and use it in GitHub Desktop.
Save HuangJiaLian/722a284329ea0f2179c6291ca2032b6d to your computer and use it in GitHub Desktop.
Arrow key to change tempo
def arrow_down(event):
global tempo, scale, tempo_range
if tempo -1 >= tempo_range[0]:
tempo -= 1
scale.set(tempo)
def arrow_up(event):
global tempo, scale, tempo_range
if tempo +1 <= tempo_range[-1]:
tempo += 1
scale.set(tempo)
def arrow_left(event):
global tempo, scale, tempo_range
if tempo - 10 >= tempo_range[0]:
tempo -= 10
else:
tempo -= (tempo-tempo_range[0])
scale.set(tempo)
def arrow_right(event):
global tempo, scale, tempo_range
if tempo + 10 <= tempo_range[1]:
tempo += 10
else:
tempo += (tempo_range[1]-tempo)
scale.set(tempo)
window.bind("<Key>",key_pressed)
window.bind('<Down>', arrow_down)
window.bind('<Up>', arrow_up)
window.bind('<Left>', arrow_left)
window.bind('<Right>', arrow_right)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment