views:

71

answers:

2

How do I combine:

button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("Green"))
button.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.color_parse("Green"))
button.modify_bg(gtk.STATE_SELECTED, gtk.gdk.color_parse("Green"))

etc.

Into a one-liner wildcard covering all of the possible states (See Doc)

+1  A: 

I do not think you can do that. You can still do it with fewer lines though:

states = [gtk.STATE_NORMAL, gtk.STATE_ACTIVE, gtk.STATE_PRELIGHT,
          gtk.STATE_SELECTED, gtk.STATE_INSENSITIVE]

for state in states:
    button.modify_bg(state, gtk.gdk.color_parse("Green"))
DoR
A: 

EDIT:

Maybe this comes in handy: http://faq.pygtk.org/index.py?req=show&file=faq04.006.htp

iElectric
When I use "or", it only respects the last item ie. gtk.STATE_ACTIVE
Toucan