Frame background color

Developing a wxPython app for cross-platform (Windows, Linux & Mac). So far I’ve only tested on Windows, and this is the main target.

The following is with Python3.6 wxPython “Phoenix” 4.0.7.post2 (wxWidgets vc140_x64)
Windows 10 18362 “1903”

The app has a Frame and a Dialog.

Without any background setup : the Frame is dark-grey and the Dialog is light grey.
self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_WINDOW ) )
–> light background
self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_MENU ) )
–> white background

So this is exactly like Dialog uses COLOUR_MENU and Frame uses COLOUR_APPWORKSPACE by default for the background.
To get a light grey bg as I expect for the Frame, I need to use myframe.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENU))

What are the default background colors for Frame, for Dialog?
What I observe is the correct and expected behaviour? Dialog has MENU color background?
Dialog and Frame have a different default background color?
Also, to me, the default color “APPWORKSPACE” should be light grey for Frame (as the Dialog).

Testing on a Debian 9 with Python 3.6 and LXDE (GTK+3 and openbox) and the Adwaita GUI window look.

Without any background setup : the Frame and the Dialog are same background color and are light grey.

So I ended up removing all background color related setup and I added :

if platform == "win32":
	frm.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_MENU ) )

This way, the different app windows look the same on WIndows and Linux. Main Frame and child Dialog have light grey background.

When targeting Windows, you should always place a panel on the frame first.
To quote from the wxGlade help:

On some platforms, I think mainly Windows, the panel is responsible for the navigation through the controls.
Without the panel you can’t use Tab and Shift+Tab to navigate through the controls.
Also on Windows the background colour of the plain frame will look darker than usual.

Very interesting, thank you!
The main issue was indeed that Windows is not rendering the main frame as the same light-grey color as the others frames. But in Linux (tested on Gnome3 and LXDE), the frames have all the same bg color.

This added panel in the frame won’t bring new compatibility issues? I mean the behavior will be the same whatever the platform? Also I understand this solves the “tab” issue. Not really an issue for our system, but good to know.

An added note about this topic in the Frame documentation page, stating that the first “app” frame is different and needs a panel, else it will be darker and tabs won’t work on Windows, wold be great for next developers.

If the frame is mainly going to contain input widgets then you should always use a panel and make the widgets use the panel as their parent. This is by design in wxWidgets, and is how it’s intended to be on all platforms. The frame and the panel have different responsibilities, but like many things in wx, doing things in a non-intended way will sometimes work okay in some environments but not in others, and can lead to confusions like this. It’s unfortunate, but once you learn about the quirks and intended usages then it’s not too onerous.

If the frame is going to contain some other kind of container, like a wx.Notebook or wx.SplitterWindow, or something else that is not input widgets, like a graphical plot or something, then that initial panel is not needed and you can just create that other thing as the frame’s direct child.