views:

237

answers:

1
+4  A: 

Here's a little example:

import gtk

win = gtk.Window()
win.connect("destroy", gtk.main_quit)

btn = gtk.Button("test")

#make a gdk.color for red
map = btn.get_colormap() 
color = map.alloc_color("red")

#copy the current style and replace the background
style = btn.get_style().copy()
style.bg[gtk.STATE_NORMAL] = color

#set the button's style to the one you created
btn.set_style(style)

win.add(btn)
win.show_all()

gtk.main()
JasonFruit
ooh finally. that actually works. i saw an example like this, but the website i saw it on said that .modify_bg was invented to avoid having to do stuff like this. thanks!!
Claudiu
i wish i could upvote you more than once.
Claudiu