pygtk更改gtkHBox小部件的背景颜色

发布于 2024-11-30 06:51:18 字数 233 浏览 1 评论 0原文

我有一个 GTK ui,它有一个 gtkVBox,可以在用户工作时动态添加 gtkHbox 的包含内容。

用户界面变得越来越拥挤,很难分辨组件属于哪个 Hbox(它们会重复)。

我想更改 gtkHbox 的背景颜色,以便每个组件在较亮和较暗的颜色之间交替。

基本上,我正在创建一个组合框的动态表,其中每一行代表一个对象。现在我需要对行进行分段,因为它们非常复杂且难以理解。

谢谢, 戴夫.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

洒一地阳光 2024-12-07 06:51:18

根据文档,由于hbox“没有关联窗口”,不能直接修改背景颜色。文档建议将其包装在事件框中。这非常有效:

hbox = gtk.HBox()
eb = gtk.EventBox()     
eb.add(hbox)
eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(red=65535))

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))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文