widget.SetBackgroundColor(widget.GetBackgroundColor()) changes the background color

Hello,

I've been trying to make my app look nice on Ubuntu (lucid). I tried
using `.GetBackgroundColor()` for a few widgets in order to know what
the background color is. I was surprised when I got a background color
which was darker than the actual background color. I've been trying to
figure out where my mistake is. Eventually I tried:

    widget.SetBackgroundColor(widget.GetBackgroundColor())

And the widget got his background color changed to a darker one!

What's up? Why is this happening? Why am I not getting the widget's
true background color?

Thanks,
Ram.

On Fedora, I discovered the same thing, and found that if I subtracted
5 from the integer RGB values as reported by GetBackgroundColour(), I
got the true default background color. I used a screen capture with
GIMP to figure out the true RGB values. On the Mac it appears to be
(224, 224, 224) and on Windows (255, 255, 255).

Dan

···

On Aug 23, 5:32 am, cool-RR <ram.rac...@gmail.com> wrote:

Hello,

I've been trying to make my app look nice on Ubuntu (lucid). I tried
using `.GetBackgroundColor()` for a few widgets in order to know what
the background color is. I was surprised when I got a background color
which was darker than the actual background color.

Probably because the theme or perhaps some parent (such as a notebook) is changing it. It may also be that the background "color" is actually a texture (a bitmap) by default instead of a solid color, and that the color being reported is just a close approximation of the texture. So when you tell it to set the bg color using the approximation it switches to painting a solid color instead of the bitmap.

To tell wx to use the platform or theme's default color or texture then you can do this:

  widget.SetBackgroundColour(wx.NullColour)

···

On 8/23/10 2:32 AM, cool-RR wrote:

Hello,

I've been trying to make my app look nice on Ubuntu (lucid). I tried
using `.GetBackgroundColor()` for a few widgets in order to know what
the background color is. I was surprised when I got a background color
which was darker than the actual background color. I've been trying to
figure out where my mistake is. Eventually I tried:

     widget.SetBackgroundColor(widget.GetBackgroundColor())

And the widget got his background color changed to a darker one!

What's up? Why is this happening? Why am I not getting the widget's
true background color?

--
Robin Dunn
Software Craftsman

This doesn’t work. I get complete black as my background color.

I’ve been trying to do the wx.SystemSettings.GetColour(wx.SYS_COLOUR_*) stuff to get the background color in a cross-platform way. I simply can’t figure this out. I’m looking for the default background color for widgets. I try wx.SYS_COLOUR_BACKGROUND and a few other ones with promising names, but on my XP machine I just get weird colors.

The widget background color for Windows XP, in the classic theme, is wx.Colour(212, 208, 200, 255). But:

wx.SystemSettings.GetColour(wx.SYS_COLOUR_APPWORKSPACE) == wx.Colour(128, 128, 128, 255)

wx.SystemSettings.GetColour(wx.SYS_COLOUR_BACKGROUND) == wx.Colour(0, 0, 0, 255)

wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW) ==

wx.Colour(255, 255, 255, 255)

What’s going on? How can I find out the widget background color in a cross-platform way?

Ram.

···

On Mon, Aug 23, 2010 at 8:36 PM, Robin Dunn robin@alldunn.com wrote:

On 8/23/10 2:32 AM, cool-RR wrote:

Hello,

I’ve been trying to make my app look nice on Ubuntu (lucid). I tried

using .GetBackgroundColor() for a few widgets in order to know what

the background color is. I was surprised when I got a background color

which was darker than the actual background color. I’ve been trying to

figure out where my mistake is. Eventually I tried:

 widget.SetBackgroundColor(widget.GetBackgroundColor())

And the widget got his background color changed to a darker one!

What’s up? Why is this happening? Why am I not getting the widget’s

true background color?

Probably because the theme or perhaps some parent (such as a notebook) is changing it. It may also be that the background “color” is actually a texture (a bitmap) by default instead of a solid color, and that the color being reported is just a close approximation of the texture. So when you tell it to set the bg color using the approximation it switches to painting a solid color instead of the bitmap.

To tell wx to use the platform or theme’s default color or texture then you can do this:

    widget.SetBackgroundColour(wx.NullColour)

Robin Dunn

And now I’m getting a similar confusion on Mac. The real background color is (232, 232, 232), but not even one color of the SYS_COLOUR_* types gets this value. What’s going on?

Ram.

···

On Mon, Aug 23, 2010 at 11:31 PM, cool-RR cool-rr@cool-rr.com wrote:

On Mon, Aug 23, 2010 at 8:36 PM, Robin Dunn robin@alldunn.com wrote:

On 8/23/10 2:32 AM, cool-RR wrote:

Hello,

I’ve been trying to make my app look nice on Ubuntu (lucid). I tried

using .GetBackgroundColor() for a few widgets in order to know what

the background color is. I was surprised when I got a background color

which was darker than the actual background color. I’ve been trying to

figure out where my mistake is. Eventually I tried:

 widget.SetBackgroundColor(widget.GetBackgroundColor())

And the widget got his background color changed to a darker one!

What’s up? Why is this happening? Why am I not getting the widget’s

true background color?

Probably because the theme or perhaps some parent (such as a notebook) is changing it. It may also be that the background “color” is actually a texture (a bitmap) by default instead of a solid color, and that the color being reported is just a close approximation of the texture. So when you tell it to set the bg color using the approximation it switches to painting a solid color instead of the bitmap.

To tell wx to use the platform or theme’s default color or texture then you can do this:

    widget.SetBackgroundColour(wx.NullColour)

Robin Dunn

This doesn’t work. I get complete black as my background color.

I’ve been trying to do the wx.SystemSettings.GetColour(wx.SYS_COLOUR_*) stuff to get the background color in a cross-platform way. I simply can’t figure this out. I’m looking for the default background color for widgets. I try wx.SYS_COLOUR_BACKGROUND and a few other ones with promising names, but on my XP machine I just get weird colors.

The widget background color for Windows XP, in the classic theme, is wx.Colour(212, 208, 200, 255). But:

wx.SystemSettings.GetColour(wx.SYS_COLOUR_APPWORKSPACE) == wx.Colour(128, 128, 128, 255)

wx.SystemSettings.GetColour(wx.SYS_COLOUR_BACKGROUND) == wx.Colour(0, 0, 0, 255)

wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW) ==

wx.Colour(255, 255, 255, 255)

What’s going on? How can I find out the widget background color in a cross-platform way?

Ram.


Sincerely,
Ram Rachum

I'm not sure, something must have changed since the last time I paid close attention to the color setting code. Describing these issues in a Trac ticket may help get some answers...

···

On 8/23/10 2:31 PM, cool-RR wrote:

What's going on? How can I find out the widget background color in a
cross-platform way?

--
Robin Dunn
Software Craftsman

Okay, here’s the ticket:

http://trac.wxwidgets.org/ticket/12389

Ram.

···

On Tue, Aug 24, 2010 at 1:26 AM, Robin Dunn robin@alldunn.com wrote:

On 8/23/10 2:31 PM, cool-RR wrote:

What’s going on? How can I find out the widget background color in a

cross-platform way?

I’m not sure, something must have changed since the last time I paid close attention to the color setting code. Describing these issues in a Trac ticket may help get some answers…

Robin Dunn