【问题标题】:GTK TreeView stylingGTK 树视图样式
【发布时间】:2017-08-07 12:18:02
【问题描述】:

短版:可以使用什么 CSS 选择器来设置 GTK TreeView 标题的背景样式?

长版:我尝试将treeview headertreeview header .button.buttonbuttonlabelGtkTreeView headerheader* 作为 Gtk 标题的选择器。树视图。其中,button 用于更改标题中文本的颜色(color 属性),而不是背景(background-color)。 label 更改标题文本后面的背景颜色,但在默认情况下会在文本周围留下很大的区域。 * 有效,但当然也改变了其他一切。

【问题讨论】:

    标签: css treeview gtk3 pygobject gtktreeview


    【解决方案1】:

    我尝试在一个简单的 python 示例中使用Gtk Inspector,它报告树视图类为 .view,标题上的按钮为 .button。为应用程序设置自定义 css 提供程序:

    cssProvider = Gtk.CssProvider()
    cssProvider.load_from_path("custom.css")
    Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
    

    以及包含以下内容的custom.css文件:

    .view .button { color: Red; background: Cyan; font-weight: bold; text-shadow: none; box-shadow: none; }
    

    结果是:

    在这里您可以看到字体颜色为红色和背景为青色的树形视图标题。

    在 Fedora 23 上测试。

    编辑

    在 Fedora 26 上,如文档所述。你应该使用:

    treeview.view header button { color: Red; background: Cyan; font-weight: bold; text-shadow: none; box-shadow: none; }
    

    结果也差不多。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多