Michael Clerx
Michael Clerx

Reputation: 3056

wx controls using a different background colour than they specify

If I run

panel.SetBackgroundColour(panel.GetBackgroundColour())

on a wxPython panel, the colour changes! What's happening here? And how do I get the real colour being used?

Upvotes: 0

Views: 325

Answers (1)

RobinDunn
RobinDunn

Reputation: 6306

If your current GTK theme uses a texture for the background then it probably defines an approximate match for the background color, which is what you get from GetBackgroundColour. By passing that to the setter you're telling the window to use that color instead of the texture.

Another possibility is if the theme alters the default color in certain contexts, such as what Windows will do if the panel is a page in a notebook. By setting the color to something else (even if it's the default) then you are overriding the theme and it will not do whatever it is doing to the windows color.

Upvotes: 4

Related Questions