1

根据http://www.pygtk.org/docs/pygtk/gtk-constants.html,有五种状态类型:STATE_NORMALSTATE_INSENSITIVE等。我想设置 Table、HBox、VBox 等的背景颜色,以及我尝试设置每种状态的所有可能颜色:

    style = self.get_style()
    for a in (style.base, style.fg, style.bg,
              style.light, style.dark, style.mid,
              style.text, style.base, style.text_aa):
        for st in (gtk.STATE_NORMAL, gtk.STATE_INSENSITIVE,
                   gtk.STATE_PRELIGHT, gtk.STATE_SELECTED,
                   gtk.STATE_ACTIVE):
            a[st] = gtk.gdk.Color(0, 34251, 0)

没有任何效果。唯一有任何影响的是当我手动创建 EventBoxes 并专门使用现有的 gtk.STATE_NORMAL 颜色与其他颜色混合时。不过,在我没有干预的情况下由 gtk 创建的所有内容都没有受到影响。

这样做的正确方法是什么?我不介意必须制作一个 gtkrc 文件或其他任何东西。这是因为hbox、vbox等没有颜色,而是透明的吗?那么,谁提供应用程序的一般颜色呢?

4

3 回答 3

2

Mostly google-fu (no windows here), posting as an "answer" mostly for a slightly better formatting. See if experimenting with the full-blown gtkrc like the one from here brings the fruits. The location, based on this and this appears to vary - so unless someone has the deterministic approach of finding it, filemon could be a sensible approach.

Being mostly a user for these kinds of apps, I would prefer the settings from my gtkrc over the hardcoded by what the programmer thought would be "the best", anytime.

于 2009-08-06T23:23:24.527 回答
1

这是因为 VBox 和 Hbox 没有关联的 Window。 单击此处查看其他没有 Windows 的小部件。我会创建事件框并在事件框内添加 HBox 或 VBox。

于 2009-08-07T00:47:49.587 回答
0

您需要self.set_style(style)在更改样式后调用。我使用您的代码作为模板,添加该行会使所有内容的背景变为绿色。

于 2011-03-22T23:07:37.317 回答