Wildcard for PyGTK States
Question
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)
Solution
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"))
OTHER TIPS
EDIT:
Maybe this comes in handy: http://faq.pygtk.org/index.py?req=show&file=faq04.006.htp
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow