I want to send a variable to a function from dynamically created buttons (14 of them)
# creating buttons
for i in range(0, 14):
m_pauser.append(wx.Button(panel, 5, "Pause "+str(i)))
m_pauser[i].Bind(wx.EVT_BUTTON, lambda event: self.dispenser_pause(event, i), m_pauser[i])
box.Add(m_pauser[i], 0, wx.ALL, 10)
# function called by buttons
def dispenser_pause(self, event, my_value):
print my_value
The problem is that all buttons always send 13 (the last value of 'i' in the 'for' loop)
How can I assign a value to a button so it sends it to the function? Is this the right way to make it work?
I just started with Python, so probably there's a lot that I'm missing out
Thanks