Reputation: 711
Created my first button panel using wx.lib.agw.buttonpanel
.
It has numerous buttons, And i need to change a specific button's image on a specific event , How can i do that ?
Currently i recreate the whole panel, looking for a better way.
Here how i create them :
for count, png in enumerate(self.pngs):
shortHelp = short_help[count]
kind = wx.ITEM_NORMAL
longHelp = long_help[count]
btn = bp.ButtonInfo(self.titleBar, wx.NewId(),
png[0], kind=kind,
shortHelp=shortHelp)
self.titleBar.AddButton(btn)
self.Bind(wx.EVT_BUTTON, OnButtonFunc[count], id=btn.GetId())
self.titleBar.AddSeparator()
Upvotes: 0
Views: 671
Reputation: 22433
With a normal wx.BitmapButton
you can use the event
to change the image. I don't know if you will get the same mileage with a wx.lib.agw.buttonpanel
.
You will need to store the image to swap to, against the Id
of the button, then use the event to swap the image.
def MyButtonFunction(self, event):
ButtonId = event.GetId()
#Map the Id to the image here#
event.GetEventObject().SetBitmap(wx.Bitmap('/path/to/button/image/swap.png'))
Upvotes: 1