# Changing the color of buttons

**URL:** <https://www.ruby-forum.com/t/changing-the-color-of-buttons/134987>\
**Category:** wxRuby\
**Created:** [April 16, 2008, 9:11pm UTC](https://www.ruby-forum.com/t/changing-the-color-of-buttons/134987 "2008-04-16T21:11:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![erubin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/82dd89/32.png) [@erubin](https://www.ruby-forum.com/u/erubin)\
**Post date:** [April 16, 2008, 9:11pm UTC](https://www.ruby-forum.com/t/changing-the-color-of-buttons/134987/1 "2008-04-16T21:11:11Z")

</div>

I’m having trouble changing the color of Buttons in WxRuby. I’m calling  
set\_background\_colour (and set\_foreground\_colour) and the calls return  
true,  
but the button remains gray.

In searching the documentation it seems that the problem might be  
related to  
should\_inherit\_colours, which can prohibit color changes, but the  
documentation is confusing. (Doesn’t specify whether  
should\_inherit\_colours  
should return true or false.)

Any suggestions?

Eric

---

<div class="post-metadata">

**Author:** ![erubin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/82dd89/32.png) [@erubin](https://www.ruby-forum.com/u/erubin)\
**Post date:** [April 17, 2008, 1:17am UTC](https://www.ruby-forum.com/t/changing-the-color-of-buttons/134987/2 "2008-04-17T01:17:23Z")

</div>

Eric R. wrote:

> I’m having trouble changing the color of Buttons in WxRuby. I’m  
> calling set\_background\_colour (and set\_foreground\_colour) and the  
> calls return true, but the button remains gray.

Generally a major part of wxRuby’s approach is that standard native  
controls like Wx::Button take the standard theme colours, depending on  
the user’s desktop settings. You don’t mention what platform you’re  
using, but I’d expect that some desktops just won’t permit non-standard  
colours to be used here.

If you could say more about what your application’s trying to do here,  
perhaps we could suggest a better way of desiging a UI that will achieve  
it whilst still looking harmonious. There are several other options eg  
Wx::BitmapButton.

alex
