# Gtk3 override\_color doesn't work

**URL:** <https://www.ruby-forum.com/t/gtk3-override-color-doesnt-work/237940>\
**Category:** Ruby-Gnome 2\
**Created:** [December 6, 2013, 8:28pm UTC](https://www.ruby-forum.com/t/gtk3-override-color-doesnt-work/237940 "2013-12-06T20:28:07Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [December 6, 2013, 8:28pm UTC](https://www.ruby-forum.com/t/gtk3-override-color-doesnt-work/237940/1 "2013-12-06T20:28:07Z")

</div>

Hi, I work on a project using Gtk3 & Ruby. I want to change colors of  
button and check button. So I tried like below:

checkBut = Gtk::CheckButton.new(“Png”)  
button = Gtk::Button.new(:label =\> “Cancel”)

color= Gdk::RGBA.new(2142, 42886, 46590, 65535)  
button.override\_color(:normal, color)  
checkBut.override\_color(:normal, color)

I couldn’t change colors. Also I’ve tried override\_background\_color but  
it doesn’t change. Can you suggest me something? How can I resolve the  
problem?

Thanks.

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [December 6, 2013, 8:34pm UTC](https://www.ruby-forum.com/t/gtk3-override-color-doesnt-work/237940/2 "2013-12-06T20:34:07Z")

</div>

Subject: [ruby-gnome2-devel-en] gtk3 override\_color doesn’t work  
Date: ven 06 dic 13 08:28:07 +0100

Quoting Ebru A. ([removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)):

> Hi, I work on a project using Gtk3 & Ruby. I want to change colors of  
> button and check button.

I do that (change the _background_ color) like this:

color=Gdk::RGBA::new(1.0,0.3,0.3,1.0)  
button.override\_background\_color(0,color)

Carlo

–

- 

```
    Se la Strada e la sua Virtu' non fossero state messe da 

```

parte,

- K \* Carlo E. Prelz - [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) che bisogno ci  
sarebbe
  - 

```
          di parlare tanto di amore e di rettitudine? 

```

(Chuang-Tzu)

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [December 6, 2013, 8:40pm UTC](https://www.ruby-forum.com/t/gtk3-override-color-doesnt-work/237940/3 "2013-12-06T20:40:25Z")

</div>

> I do that (change the _background_ color) like this:
> 
> color=Gdk::RGBA::new(1.0,0.3,0.3,1.0)  
> button.override\_background\_color(0,color)
> 
> Carlo
> 
> –

I tried as your suggestion but it doesn’t change.

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [December 6, 2013, 8:47pm UTC](https://www.ruby-forum.com/t/gtk3-override-color-doesnt-work/237940/4 "2013-12-06T20:47:33Z")

</div>

Subject: Re: [ruby-gnome2-devel-en] gtk3 override\_color doesn’t work  
Date: ven 06 dic 13 08:40:25 +0100

Quoting Ebru A. ([removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)):

> > I do that (change the _background_ color) like this:
> > 
> > color=Gdk::RGBA::new(1.0,0.3,0.3,1.0)  
> > button.override\_background\_color(0,color)
> 
> I tried as your suggestion but it doesn’t change.

Mah?!? Here it does (on Linux).

Carlo

–

- 

```
    Se la Strada e la sua Virtu' non fossero state messe da 

```

parte,

- K \* Carlo E. Prelz - [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) che bisogno ci  
sarebbe
  - 

```
          di parlare tanto di amore e di rettitudine? 

```

(Chuang-Tzu)

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [December 6, 2013, 8:49pm UTC](https://www.ruby-forum.com/t/gtk3-override-color-doesnt-work/237940/5 "2013-12-06T20:49:27Z")

</div>

> Mah?!? Here it does (on Linux).
> 
> Carlo
> 
> –

I’m using Ubuntu 13.04 Xfce.

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [December 6, 2013, 8:54pm UTC](https://www.ruby-forum.com/t/gtk3-override-color-doesnt-work/237940/6 "2013-12-06T20:54:00Z")

</div>

Subject: Re: [ruby-gnome2-devel-en] gtk3 override\_color doesn’t work  
Date: ven 06 dic 13 08:49:27 +0100

Quoting Ebru A. ([removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)):

> I’m using Ubuntu 13.04 Xfce.

Here I am on Debian Sid, and I use Mate. But I used to use Xfce, and  
that code worked there too.

You may want to submit the actual code…

Carlo

–

- 

```
    Se la Strada e la sua Virtu' non fossero state messe da 

```

parte,

- K \* Carlo E. Prelz - [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) che bisogno ci  
sarebbe
  - 

```
          di parlare tanto di amore e di rettitudine? 

```

(Chuang-Tzu)

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [December 6, 2013, 8:59pm UTC](https://www.ruby-forum.com/t/gtk3-override-color-doesnt-work/237940/7 "2013-12-06T20:59:12Z")

</div>

> Here I am on Debian Sid, and I use Mate. But I used to use Xfce, and  
> that code worked there too.
> 
> You may want to submit the actual code…
> 
> Carlo
> 
> –

require ‘gtk3’

w = Gtk::Window.new

layout = Gtk::Layout.new  
checkBut = Gtk::CheckButton.new(“Png”)  
button = Gtk::Button.new(:label =\> “Cancel”)

color=Gdk::RGBA::new(1.0,0.3,0.3,1.0)  
button.override\_background\_color(0,color)  
w.signal\_connect(‘destroy’){Gtk.main\_quit}  
w.set\_size\_request(350, 350)

layout.put(checkBut, 80, 100)  
layout.put(button, 80, 150)

w.add(layout)  
w.show\_all  
Gtk.main

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [December 6, 2013, 9:10pm UTC](https://www.ruby-forum.com/t/gtk3-override-color-doesnt-work/237940/8 "2013-12-06T21:10:21Z")

</div>

Subject: Re: [ruby-gnome2-devel-en] gtk3 override\_color doesn’t work  
Date: ven 06 dic 13 08:59:12 +0100

Quoting Ebru A. ([removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)):

> button.override\_background\_color(0,color)  
> w.signal\_connect(‘destroy’){Gtk.main\_quit}  
> w.set\_size\_request(350, 350)
> 
> layout.put(checkBut, 80, 100)  
> layout.put(button, 80, 150)
> 
> w.add(layout)  
> w.show\_all  
> Gtk.main

I ran your code. The ‘Cancel’ button is red. See attached screen dump.

If it is not red in your case, maybe you have some restrictive  
configuration… It never happened to me though.

Carlo

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [December 6, 2013, 9:22pm UTC](https://www.ruby-forum.com/t/gtk3-override-color-doesnt-work/237940/9 "2013-12-06T21:22:11Z")

</div>

> I ran your code. The ‘Cancel’ button is red. See attached screen dump.
> 
> If it is not red in your case, maybe you have some restrictive  
> configuration… It never happened to me though.
> 
> Carlo

I added screenshot. One more question, I’ll try to change my  
configuration but I don’t understand meaning:

color=Gdk::RGBA::new(1.0,0.3,0.3,1.0)

1.0, 0.3 .. How can you detect theese are supply red color? I want to  
learn, it is necessary for my project. I should supply a few different  
colors.

Thanks.

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [December 6, 2013, 9:30pm UTC](https://www.ruby-forum.com/t/gtk3-override-color-doesnt-work/237940/10 "2013-12-06T21:30:49Z")

</div>

Subject: Re: [ruby-gnome2-devel-en] gtk3 override\_color doesn’t work  
Date: ven 06 dic 13 09:22:11 +0100

Quoting Ebru A. ([removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)):

> I added screenshot. One more question, I’ll try to change my  
> configuration but I don’t understand meaning:
> 
> color=Gdk::RGBA::new(1.0,0.3,0.3,1.0)
> 
> 1.0, 0.3 .. How can you detect theese are supply red color? I want to  
> learn, it is necessary for my project. I should supply a few different  
> colors.

To generate a RGBA colour you must provide four values: red, green,  
blue, and A (the transparency value). The values must be between 0 and

1. So, 1,0,0,1 is pure red, 0,1,0,1 is pure green, etc… 1,0.3,0.3,1 is  
full red plus one third of green and blue (gives a light red - almost  
pink). If your fourth value is less than 1, it is as if your paint  
were more and more transparent - a value of 0 gives always the basic  
grey,  
regardless of the other three values.

–

- 

```
    Se la Strada e la sua Virtu' non fossero state messe da 

```

parte,

- K \* Carlo E. Prelz - [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) che bisogno ci  
sarebbe
  - 

```
          di parlare tanto di amore e di rettitudine? 

```

(Chuang-Tzu)

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [December 6, 2013, 9:44pm UTC](https://www.ruby-forum.com/t/gtk3-override-color-doesnt-work/237940/11 "2013-12-06T21:44:25Z")

</div>

> To generate a RGBA colour you must provide four values: red, green,  
> blue, and A (the transparency value). The values must be between 0 and
> 
> 1. So, 1,0,0,1 is pure red, 0,1,0,1 is pure green, etc… 1,0.3,0.3,1 is  
> full red plus one third of green and blue (gives a light red - almost  
> pink). If your fourth value is less than 1, it is as if your paint  
> were more and more transparent - a value of 0 gives always the basic  
> grey,  
> regardless of the other three values.
> 
> –  
> Ok, thanks and I dont know where can i change this configuration. Can  
> you suggest me something for changing configuration?

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [December 6, 2013, 10:52pm UTC](https://www.ruby-forum.com/t/gtk3-override-color-doesnt-work/237940/12 "2013-12-06T22:52:37Z")

</div>

Subject: Re: [ruby-gnome2-devel-en] gtk3 override\_color doesn’t work  
Date: ven 06 dic 13 09:44:25 +0100

Quoting Ebru A. ([removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)):

> Ok, thanks and I dont know where can i change this configuration. Can  
> you suggest me something for changing configuration?

I believe it has to do with the theme you selected. Try changing  
that. But it’s a question of trial and error…

Carlo

–

- 

```
    Se la Strada e la sua Virtu' non fossero state messe da 

```

parte,

- K \* Carlo E. Prelz - [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) che bisogno ci  
sarebbe
  - 

```
          di parlare tanto di amore e di rettitudine? 

```

(Chuang-Tzu)
