【发布时间】:2016-05-29 23:56:57
【问题描述】:
使用 Tkinter,我有很多按钮。我希望每次按下任何按钮时都会触发相同的回调函数。我怎样才能知道按下了哪个按钮?
def call(p1):
# Which Button was pressed?
pass
for i in range (50):
B1 = Button(master, text = '...', width = 2)
B1.grid(row = i*20, column = 60)
B1.bind('<Button-1>',call)
B2 = Button(master, text = '...', width = 2)
B2.grid(row = i*20, column = 60)
B2.bind('<Button-1>',call)
【问题讨论】: