如何用PYGtk设置Gtk Icon主题?
16lz
2021-01-22
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")
...
更多相关文章
- android Editview中加小图标或者文字实现
- android 百度地图路线规划去掉节点图标
- 在Android主屏幕上删除启动器图标(就像Google Play一样)
- Android实现桌面图标通知数量角标
- android MPChart图标使用详解
- Android Studio错误“AppCompat不支持主题”[重复]
- 关于LSA的相关学习---短文本聚类涉及到的知识,一种主题模型(原载于
- Eclipse工程图标左下角报错
- java_easyui体系之更换主题