Search code examples
wxpython

Can we change background color of checkbox text in WxPython?


Can we change background color of checkbox text in WxPython? I want the whole region of the square box + attached text to it, to be in a particular color

checkbox = wx.CheckBox(self.panel, -1, 'Label',  (5, 5)

So the goal is to change the background color of the checkbox and label

checkbox.SetBackgroundColour('blue') only changes the square of the checkbox to blue, but I'd like everything but that (including the label's background)


Solution

  • Yes just

    import wx
    

    then define your class

    class my_window(wx.Frame):
    

    set the size

    wx.Frame.__init__(self,parent,id,'My Window', size=(300,200))
    

    and the colour

    self.SetBackgroundColour(wx.BLUE)
    

    For labels you have to use SetForegroundColor

      self.label2.SetForegroundColour("yellow")