pygtk change background color of gtkHBox widget

杀马特。学长 韩版系。学妹 提交于 2019-12-06 23:38:22

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/7127093/pygtk-change-background-color-of-gtkhbox-widget

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!