Just in case someone have my same problem, I solved it in a really non elegant way, but it works:
def update():
for i in xrange(len(buttons)):
if (buttonsStatus[i] < buttons[i].clicks): #Checking the button that has changed
print "pushed button ", i
buttonsStatus[i] = buttons[i].clicks
break;
buttons =
for i, data in enumerate(personas_data):
button_persona = Button(label=data["title"], width = 210, clicks = 0)
button_persona.on_click(update)
buttons.append(button_persona)
buttonsStatus = np.zeros((len(buttons), 1))
``
···
El viernes, 23 de septiembre de 2016, 12:32:35 (UTC+2), Roberto González Sánchez escribió:
Hi all,
I have a figure that should be modified depending on the clicked button.
I’m generating the buttons like this:
def update(value):
print "pushed button ", value
for i, data in enumerate(personas_data):
button_persona = Button(label=data["title"], width = 210)
button_persona.on_click(lambda: update(i))
``
But, when I click a button, it always receive the index of the last one. So, I cannot know the button the user is clicking.
Is there an easy way to do this?
Thanks