I am trying to use an RC file to set the background colour of a button. I am 
able to change the colour of the font usinf the RC file, but not the background 
colour or font. I am able to change the background of the window. The RC file 
is;

style "window"

{

font = "-Adobe-Times-Bold-I-Normal--14-100-100-100-P-77-ISO8859-1"

# Yellow background

bg[NORMAL] = {1.0, 1.0, 0}

}


style "button"

{

font = "-Adobe-Times-Bold-I-Normal--14-100-100-100-P-77-ISO8859-1"


# Change font colour, WORKS

fg[PRELIGHT] = { 0, 0, 1.0 }

fg[ACTIVE] = { 0, 1.0, 0 }

fg[NORMAL] = { 1.0, 0, 0 }

fg[INSENSITIVE] = { 1.0, 1.0, 0 }

#Try to change background colour, DOES NOT WORK

bg[PRELIGHT] = { 0, 0, 1.0 }

bg[ACTIVE] = { 0, 1.0, 0 } 

bg[INSENSITIVE] = { 1.0, 1.0, 0 }

bg[NORMAL] = { 0, 1.0, 1.0 }





base[PRELIGHT] = { 0, 0, 1.0 }

base[ACTIVE] = { 0, 0, 1.0 }

base[NORMAL] ={ 0, 0, 1.0 }

base[INSENSITIVE] = { 0, 0, 1.0 }


}


widget_class "GtkWindow" style "window"

widget_class "*GtkButton*" style "button"



I am able to set the colour of the button by editing the style in this method;

def setWidgetColour(widget, colour_string):

""" Takes a widget and sets the colour. """

r, g, b = colourToRGB16Bit(colour_string)

color = widget.get_colormap().alloc_color(r, g, b)


s = widget.get_style().copy()

for i in range(5):

s.fg[i] = color

s.bg[i] = color

s.base[i] = color

widget.set_style(s) 

The problem is that when I use this method I lose the rounded corners which I 
want to keep. Plus I'd rather use the RC files for ease of modification.

Having searched around for similar problems some people say that you need to 
set the colour of the label, but then some people say that the label is 
invisible. Others say you need to add the Button to a gtk.EventBox, so I'm a 
little confused

I am using the most recent version of PyGTK (as of yesterday) with Python2.5. 

Any help would be greatly appreciated- Thanks
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to