钢琴Python中的键盘绑定



如何使用python gui在钢琴中绑定键盘?

我尝试使用绑定,但我不知道如何使用。

btnCs = Button(ABC2,  height = 6, width = 6, bd = 4, text = "C#", font =('arial', 18 , 'bold'), bg = "black",  fg = "white", command = value_Cs)

我希望使用给定代码的示例帮助我

按下键盘中的a键时,请观察控制台输出。您需要使用鼠标将TKINTER窗口聚焦。需要event=None,因为bended回调函数通过TKINTER事件循环(Mainloop(传递了事件对象:

from tkinter import Tk
def play_a(event=None):
    print('Play the A key sound')
root = Tk()
root.bind('a', play_a)
root.mainloop()

最新更新