开发者

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 ro开发者_如何学Gows since they are quiet complex and hard to follow.

Thanks, Dave.


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))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜