Search code examples
pythonwindowsuser-interfacewxpythonpanel

wxPython panel color does not match with frame background


While using wxPython in creating GUI for Windows, I am encountering a problem where the wx.Panel's background colour and parent frame's background colours are not matching (one is light gray while the other one is of darker hue). However, this is not evident in Linux with the same code. How can I match the two different background colours in Windows? The embedded screenshot may give a fair idea of what I am talking about. !Screenshot of the GUI1


Solution

  • Create a container panel that has the wx.Frame as parent (hence you get the light gray background color for the frame).
    Use this panel as parent for all widgets contained in the frame.

    Edit: the only reason is that default background color for frames is dark grey on Windows, see WxFAQ.