哪些GTK +元素支持哪些CSS属性? [英] Which GTK+ elements support which CSS properties?

查看:239
本文介绍了哪些GTK +元素支持哪些CSS属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将自己的CSS应用到我的GTK +应用程序时,我注意到一些元素忽略了一些CSS属性,而其他元素忽略了其他元素或者不忽略它们,这导致我搜索哪些元素支持哪些CSS属性。



例如 Gtk .Label 根本不支持 border ,我不得不放置 Gtk.Frame >围绕它并在CSS文件中设置样式。另一个问题是,即使是 Gtk.Frame 也不支持 margin ,我想使用它。



任何人都可以给我一些指示,告诉我在哪里可以找到它?
(或者如果我误解了所有这些,我该如何让这些元素支持CSS属性?)

解决方案

这里是GTK 3.8支持哪些CSS属性的概述。相同的信息主要包含在 GtkCssProvider ,尽管不是表格形式。



哪些小部件支持哪些属性有点困难。它归结为两种小部件:那些简单且只支持基本样式(无边框或背景)的小部件,例如 GtkLabel ;以及那些支持所有属性的文件,比如 GtkFrame 。如你所发现的,在 GtkFrame GtkEventBox 中包装一个简单的小部件是将一个小部件变成其他。



保证金属性完全不受支持,我被告知这是一个选择。 GTK开发者。据我的理解,思考的是,GTK不是HTML,并且屏幕上的小部件布局应该由您的代码来管理,而不是由CSS来管理。

GTK 3.20中的更新:大多数或所有小部件现在都支持 margin CSS属性。


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?)

解决方案

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.

这篇关于哪些GTK +元素支持哪些CSS属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆