Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This may be what you are looking for. It is c++, but hopefully you can translate it to the python equivalent. The code changes the background color of a widget in different states.</p> <pre><code>void changeColor(Gtk::Widget* widget, double r, double g, double b) { Glib::RefPtr&lt;Gdk::Colormap&gt; colormap = widget-&gt;get_colormap(); Glib::RefPtr&lt;Gtk::Style&gt; style = widget-&gt;get_style()-&gt;copy(); // STATE_NORMAL (most of the time) { Gdk::Color color; color.set_rgb_p(r,g,b); // &lt;-- customize this colormap-&gt;alloc_color(color); style-&gt;set_bg(Gtk::STATE_NORMAL, color); } // STATE_PRELIGHT (when mouse hovers) { Gdk::Color color; color.set_rgb_p(r*0.9,g*0.9,b*0.9); // &lt;-- customize this colormap-&gt;alloc_color(color); style-&gt;set_bg(Gtk::STATE_PRELIGHT, color); } // STATE_ACTIVE (when clicked) { Gdk::Color color; color.set_rgb_p(r*0.8,g*0.8,b*0.8); // &lt;-- customize this colormap-&gt;alloc_color(color); style-&gt;set_bg(Gtk::STATE_ACTIVE, color); } widget-&gt;set_style(style); } </code></pre> <p>You are interested in setting the right colors in the STATE_PRELIGHT block so that they are the same than in the STATE_NORMAL block. (I'm guessing this is what you mean with your question).</p> <p>By the way, there are two other states which are not handled in the method above: STATE_SELECTED and STATE_INSENSITIVE. It must also be stated that this function, despite its name, doesn´t actually change the color of any widget. It won't change the color of a label, for example, since a label takes the color of it's container. So don't take the function signature too seriously.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload