Which GTK+ elements support which CSS properties?

女生的网名这么多〃 提交于 2019-12-22 06:35:31

问题


While applying my own CSS to my GTK+ application, I noticed, that some elements ignore some CSS properties and others ignore others or don't ignore them, which leads me to search for an overview of which elements support which CSS properties.

So far I couldn't find any such overview.

For example Gtk.Label doesn't support border at all, I had to put a Gtk.Frame around it and style that in the CSS file. Another issue is, that even a Gtk.Frame doesn't support margin, which I want to use.

Can anyone give me some direction on where to find that? (Or if I am mistaken with all of this, how do I make the elements support CSS properties?)


回答1:


Here is an overview of which CSS properties are supported as of GTK 3.8. The same information is mostly contained in the documentation for GtkCssProvider, albeit not in table form.

Which widgets support which properties is a bit harder. It boils down to two kinds of widgets: those that are simple and only support basic styling (no borders or backgrounds), such as GtkLabel; and those that support all properties, such as GtkFrame. Wrapping a simple widget inside a GtkFrame or GtkEventBox, as you have discovered, is the usual way to turn one into the other.

The margin property is not supported at all, and I'm told that this is a choice by the GTK developers. The thinking goes, as I understand it, that GTK is not HTML, and the layout of your widgets on screen should be governed by your code and not by CSS.

Update in GTK 3.20: The margin CSS property is now supported across most or all widgets.



来源:https://stackoverflow.com/questions/32162372/which-gtk-elements-support-which-css-properties

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!