本文整理汇总了Python中ubuntutweak.conf.GconfSetting.get_key方法的典型用法代码示例。如果您正苦于以下问题:Python GconfSetting.get_key方法的具体用法?Python GconfSetting.get_key怎么用?Python GconfSetting.get_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ubuntutweak.conf.GconfSetting
的用法示例。
在下文中一共展示了GconfSetting.get_key方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GconfComboBox
# 需要导入模块: from ubuntutweak.conf import GconfSetting [as 别名]
# 或者: from ubuntutweak.conf.GconfSetting import get_key [as 别名]
class GconfComboBox(gtk.ComboBox):
def __init__(self, key=None, texts=None, values=None):
super(GconfComboBox, self).__init__()
self.__setting = GconfSetting(key=key)
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
self.set_model(model)
cell = gtk.CellRendererText()
self.pack_start(cell, True)
self.add_attribute(cell, 'text', 0)
current_value = self.__setting.get_value()
for text, value in dict(zip(texts, values)).items():
iter = model.append(None)
model.set(iter, 0, text, 1, value)
if current_value == value:
self.set_active_iter(iter)
self.connect("changed", self.value_changed_cb)
def value_changed_cb(self, widget):
iter = widget.get_active_iter()
text = self.get_model().get_value(iter, 1)
log.debug("GconfComboBox value changed to %s" % text)
self.__setting.get_client().set_value(self.__setting.get_key(), text)
示例2: GconfEntry
# 需要导入模块: from ubuntutweak.conf import GconfSetting [as 别名]
# 或者: from ubuntutweak.conf.GconfSetting import get_key [as 别名]
class GconfEntry(gtk.Entry):
def __init__(self, key=None, default=None):
gtk.Entry.__init__(self)
self.__setting = GconfSetting(key=key, default=default, type=str)
string = self.__setting.get_value()
if string:
self.set_text(string)
else:
self.set_text(_("Unset"))
def is_changed(self):
return self.get_string_value() != self.get_text()
def get_string_value(self):
return self.__setting.get_value()
def connect_activate_signal(self):
self.connect('activate', self.on_edit_finished_cb)
def get_gsetting(self):
return self.__setting
def reset(self):
self.set_text(self.get_string_value())
def on_edit_finished_cb(self, widget):
string = self.get_text()
client = self.__setting.get_client()
key = self.__setting.get_key()
if string:
client.set_string(key, self.get_text())
else:
client.unset(key)
self.set_text(_("Unset"))