My code,
self.one = wx.Button(self, -1, "Add Button", pos = 100,20)
self.one.Bind(wx.EVT_BUTTON, self.addbt)
self.x = 50
self.idr = 0
self.btarr = []
def addbt(self.event)
self.button = wx.Button(self, self.idr, "Button 1", pos = (self.x,100))
self.button.Bind(wx.EVT_BUTTON, self.OnId)
self.idr+=1
self.x +=150
self.btarr.append(self.button)
def OnId(self, Event):
print "The id for the clicked button is: %d" % self.button.GetId()
#I wanna print id of indivual buttons clicked
I use the above code to create multiple buttons dynamically. All the created buttons have the same reference name. On clicking each button I should get respective individual ids. But all I am getting is the ID of the last button created. How do I print indivual Ids of the buttons?
Thanks in advance!