Created
March 31, 2022 15:31
-
-
Save HuangJiaLian/722a284329ea0f2179c6291ca2032b6d to your computer and use it in GitHub Desktop.
Arrow key to change tempo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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