Send variables in dynamically created buttons with wxPython
问题 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