How can I set the global system icon theme with Python (PYGtk 3)?

如何使用Python(PYGtk 3)设置全局系统图标主题?

This is returning the current Icon Theme in the system. It works perfect.

这将返回系统中的当前图标主题。它完美无缺。

from gi.repository import Gtk, GObject, Gio, GLib
print(Gtk.Settings.get_default().get_property("gtk-icon-theme-name"))

But I can't set it. I tried this, but without a result:

但我无法设定它。我尝试了这个,但没有结果:

from gi.repository import Gtk, GObject, Gio, GLib
Gtk.Settings.get_default().set_property("gtk-icon-theme-name", "Numix")

Thanks!

谢谢!

1 个解决方案

#1


1

You have to check that the directory of the theme you want exists in /path/to/Python/x.x/Lib/site-packages/gnome/share/themes/.

您必须在/path/to/Python/x.x/Lib/site-packages/gnome/share/themes/中检查所需主题的目录。

Then, before the program/script initialises the Gtk Window, set the theme to use:

然后,在程序/脚本初始化Gtk窗口之前,设置要使用的主题:

from sys import stderr, exit
try:
    import gi
    gi.require_version('Gtk', '3.0')
    from gi.repository import Gtk, Gdk, GObject, Gio, GLib
except (ImportError, ImportWarning):
    stderr.write("Could not import GTK. Please install it.")

class HelloWindow(Gtk.Window):

    def __init__(self):
        Gtk.Settings.get_default().set_property("gtk-icon-theme-name", "Numix")
        Gtk.Settings.get_default().set_property("gtk-theme-name", "MS-Windows-XP")
        Gtk.Window.__init__(self, title="Hello World")
        ...

更多相关文章

  1. android Editview中加小图标或者文字实现
  2. android 百度地图路线规划去掉节点图标
  3. 在Android主屏幕上删除启动器图标(就像Google Play一样)
  4. Android实现桌面图标通知数量角标
  5. android MPChart图标使用详解
  6. Android Studio错误“AppCompat不支持主题”[重复]
  7. 关于LSA的相关学习---短文本聚类涉及到的知识,一种主题模型(原载于
  8. Eclipse工程图标左下角报错
  9. java_easyui体系之更换主题

随机推荐

  1. 熔断器 Hystrix 源码解析 —— 命令执行(
  2. 数据库分库分表中间件 Sharding-JDBC 源
  3. 【招聘】杭州阿里招高级前端
  4. 【招聘】上海携程门票业务招中高级前端
  5. 分布式消息队列 RocketMQ 源码分析 ——
  6. 熔断器 Hystrix 源码解析 —— 执行结果
  7. 【第557期】搭建前端私有npm杂记
  8. 【第764期】你不懂JS:this是什么?
  9. 熔断器 Hystrix 源码解析 —— 调试环境
  10. 熔断器 Hystrix 源码解析 —— 命令执行(