pygtk更改gtkHBox小部件的背景颜色 [英] pygtk change background color of gtkHBox widget

查看:166
本文介绍了pygtk更改gtkHBox小部件的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个GTK ui,它具有一个gtkVBox,该gtkVBox会在用户工作时动态添加gtkHbox包含的内容.

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

用户界面越来越拥挤,很难说出组件属于哪个Hbox(它们重复).

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

我想更改gtkHboxes的背景颜色,以便每个颜色在较亮和较暗的颜色之间交替.

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.

谢谢, 戴夫.

推荐答案

根据

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

这篇关于pygtk更改gtkHBox小部件的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆