如何在vala中更改Gtk.Label的字体大小? [英] How can I change the font size of a Gtk.Label in vala?

查看:145
本文介绍了如何在vala中更改Gtk.Label的字体大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Vala/Gtk的新手,我正在尝试更改Gtk.Label的字体大小,但是我找不到一种很好的方法.

I'm a Vala/Gtk newbie and I'm trying to change the font size of a Gtk.Label, but I can't find a good way to do it.

我发现我可以使用这样的标记:

I find out that I can use the markup like this :

    var welcome_message = new Gtk.Label ("<span size='17000'>Hello</span>");
    welcome_message.set_use_markup (true);

但是似乎有点破破烂烂. 正确的方法是什么?

But it seems a little hackish. What is the right way to do it ?

推荐答案

您可以尝试使用CSS,我认为最近这是首选方法.给您的标签一个类,然后加载一个CSS.如果您要更改标签的字体大小,我敢打赌,您还将自定义其他内容,因此CSS可能对您有用.

You could try with css, I think lately this is the preferred way. Give your label a class, then load a css. If you are going to change the font size of a label, I bet you are also going to customize other things so the css may be useful for you.

这篇关于如何在vala中更改Gtk.Label的字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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