I need the button name for my callback method because the name serves also as a key to a dictionary containing sql commands to be executed on click. I’ve tried to search if the
event passed to the callback could have some properties including the name but I have found nothing. Ther must(?) be a way of identifying the button which has been clicked. Could someone help me out with this? The format below works except for the name extraction.
class Query: def __init__(self): self.buttons = [btn_0, btn_1, btn_2] self.data = dict def callback(self, event): value = self.dict[button_name] # Run an SQL query using the value return (the query result) def bind_buttons(self): for button in self.buttons: pn.bind(callback, self.button, watch=True) query = Query() query.bind_buttons() query_buttons = pn.Column( '# Queries', query.buttons, query.buttons, query.buttons, )