How can I set a background color for everything in a GridBagSizer including empty
cells?
I’ve read that you can’t set a background for the sizer itself so what can I do?
How can I set a background color for everything in a GridBagSizer including empty
cells?
I’ve read that you can’t set a background for the sizer itself so what can I do?
Hi Paul–
wx_test_Grid_Bag_sizer.py (1.49 KB)
On Tuesday, August 27, 2013 5:19:38 PM UTC-4, Paul wrote:
How can I set a background color for everything in a GridBagSizer including
empty
cells?
I’ve read that you can’t set a background for the sizer itself so what can I do?
That’s correct. You cannot set the background color for a sizer because it isn’t actually a display, its just a container for other widgets and panels. There are many ways to ensure the color of everything in the sizers are the same color. You want to set the background color of the frame or panel that contains the sizer (self.SetBackgroundColour(wx.Colour()).
I’ve attached a file with a great example from Robin Dunn’s wxPython in Action book (If you are going to be doing wxPython regularly, I’d suggest picking up a copy). You can see I am setting the color of the panel in a couple different places (and made a couple different colors to show the effect). Play around with the colors to get the look you want.
Jake