How to make custom buttons in wx?

前端 未结 4 709
刺人心
刺人心 2021-01-05 11:47

I\'d like to make a custom button in wxPython. Where should I start, how should I do it?

4条回答
  •  梦谈多话
    2021-01-05 12:18

    You can extend the default button class, like this for example:

    class RedButton(wx.Button):
        def __init__(self, *a, **k):
            wx.Button.__init__(self, *a, **k)
            self.SetBackgroundColour('RED')
            # more customization here
    

    Every time you put a RedButton into your layout, it should appear red (haven't tested it though).

提交回复
热议问题