PyGtk3 如何更改应用程序主题? [英] PyGtk3 how to change application theme?

查看:41
本文介绍了PyGtk3 如何更改应用程序主题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Gtk.rc_parse("path/to/Hooli/gtk-3/gtk.css") 代码尝试了 rc_parse 方法,但它不起作用.这个问题很简单,但问题的解决并不容易.如何更改我的 gtk 应用程序主题?或者如何在我的 gtk 应用程序上使用自定义主题?

i tried rc_parse method using Gtk.rc_parse("path/to/Hooli/gtk-3/gtk.css") code but it is not working. this question is simlpy but solution of question not easy. how can i change the my gtk apllication theme ? or how can i use custom theme on my gtk application ?

谢谢.

推荐答案

import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk as gtk

settings = gtk.Settings.get_default()
settings.set_property("gtk-theme-name", "Numix")
settings.set_property("gtk-application-prefer-dark-theme", False)  # if you want use dark theme, set second arg to True

# getting all existing properties #

for i in settings.list_properties():
    print(i)

此代码在 windows、linux 上运行非常正常,...我希望这能解决您的问题

this codes working very correctly on windows, linux, ... i hope this solve your problem

这篇关于PyGtk3 如何更改应用程序主题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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