获取当前GTK主题的字体颜色 [英] Get font color of the current GTK theme

查看:132
本文介绍了获取当前GTK主题的字体颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取当前主题的字体颜色.

I need to get the font color of the current theme.

我发现了这个问题解释了如何使用gtk_style_lookup_color在C中执行此操作,但似乎该功能已被弃用.

I found this question that explains it how to do it in C with gtk_style_lookup_color, but it seems that the function is deprecated.

进行更多研究后,我发现了新功能 gtk_style_context_lookup_color

Making more researches I found the new function gtk_style_context_lookup_color

但是我在理解文档时遇到了问题.另外,当我尝试使用Gtk.style_context_lookup_color( .. )调用它时,我发现它不存在!

But I have problems understanding the docs. Also, when I try to call it by using Gtk.style_context_lookup_color( .. ) I get that it doesn't exists!

是因为我需要用GtkStyleContext.style_context_lookup_color(arg1,arg2)之类的东西来调用它吗?

Is it because I need to call it with something like GtkStyleContext.style_context_lookup_color(arg1,arg2) ?

推荐答案

我使用 gtk.settings.

    settings=Gtk.Settings.get_default()

    colors=settings.get_property("gtk-color-scheme")
    colors=colors.split("\n")

    for color in colors:
        if 'text' in color:
            text_color=color.split(':')[1].strip()
            print text_color
            break

"gtk-color-scheme"属性似乎存储了主题的所有颜色,因此,如果要搜索其他颜色,可以用相同的方式找到它!

It seems that the "gtk-color-scheme" property stores all the colors of the theme, so if you are searching for any other color you can find it in the same way!

这篇关于获取当前GTK主题的字体颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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