Get font color of the current GTK theme

喜欢而已 提交于 2019-11-30 09:17:26

问题


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

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.

Making more researches I found the new function 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!

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


回答1:


I found the answer using 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

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!



来源:https://stackoverflow.com/questions/27962577/get-font-color-of-the-current-gtk-theme

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