I am trying to populate the screen with multiple buttons automatically (using for loop)
Here is the snippet:
i = 0
for w in [1,2,3,4,5,6,7,8]:
by.append(wx.Button(panel,label=w,pos = wx.Point(50*i,0)))
by[i].Bind(wx.EVT_LEFT_DOWN,lambda event: self.OnClicked(event,by[i]))
i += 1
i = 0
when the event occurs, since I set the i = 0
, all of the events are routed to the first button, even if I click on the last button. I know that if I set the slot with out the for loop it would work. But lets say I need to create about 50 buttons on a screen, and I want to do it automatically. How would I set the slot?