0

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()
1
  • accepted? sorry , how do i do that? Commented Dec 31, 2017 at 12:21

1 Answer 1

1

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'))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.