【发布时间】:2012-10-23 21:02:47
【问题描述】:
如果一个 GSettings 模式存在并且已经被编译,那么读取它通常没有问题。但是,如果它不存在,通常会抛出无法处理的错误。在 Python 文件或控制台中尝试:
from gi.repository import Gio
try:
settings = Gio.Settings("com.example.doesnotexist")
except:
print "Couldn't load those settings!"
except 尽可能广泛,但这是引发的错误。
(process:10248): GLib-GIO-ERROR **: Settings schema 'com.example.doesnotexist' is not installed
我基本上想做的是找出com.example.doesnotexist 模式是否存在;如果没有,那么告诉用户在使用我的应用程序之前运行我的设置脚本。任何其他关于这样做的建议都将受到欢迎。
【问题讨论】: