Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pygtk change background color of gtkHBox widget

I have a GTK ui that has a gtkVBox that gets gtkHbox's containing content dynamically added to it as the user works.

The ui is getting crowded and it's difficult to tell what Hbox the components belong to (they repeat.)

I would like to alter the background color of the gtkHboxes so it alternates between a lighter and darker color for each one.

Basically, I'm creating a dynamic table of combo boxes where each row represents an object. Now I need to segment the rows since they are quiet complex and hard to follow.

Thanks, Dave.

like image 335
David Just Avatar asked Aug 19 '11 20:08

David Just


1 Answers

According to the docs, since hboxes "do not have an associated window", you can not directly modify the background color. The docs suggest to wrap it in and event box. This works quite well:

hbox = gtk.HBox()
eb = gtk.EventBox()     
eb.add(hbox)
eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(red=65535))
like image 113
Mark Avatar answered Sep 18 '22 14:09

Mark