短版本:什么CSS选择器可以用来对GTK TreeView头的背景进行样式设计?
长版本:我尝试过treeview header、treeview header .button、.button、button、label、GtkTreeView header、header和*作为Gtk.TreeView头的选择器。其中,button可以更改标题( color属性)中文本的颜色,而不是背景(background-color)。label会改变标题文本后面背景的颜色,但在默认情况下会在文本周围留下一个很大的区域。*可以工作,但当然也会改变其他一切。
发布于 2017-08-09 14:33:31
我尝试在一个简单的python示例中使用Gtk检查员,它将treeview类报告为.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; }结果是:

在这里,您可以看到treeview标题,字体颜色为红色,背景为Cyan。
在Fedora 23上测试过。
编辑
在Fedora 26上,这是记录在案的。你应该使用:
treeview.view header button { color: Red; background: Cyan; font-weight: bold; text-shadow: none; box-shadow: none; }结果是相似的。
https://stackoverflow.com/questions/45546717
复制相似问题