本文整理汇总了Python中ubuntutweak.conf.GconfSetting.get_value方法的典型用法代码示例。如果您正苦于以下问题:Python GconfSetting.get_value方法的具体用法?Python GconfSetting.get_value怎么用?Python GconfSetting.get_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ubuntutweak.conf.GconfSetting
的用法示例。
在下文中一共展示了GconfSetting.get_value方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GconfScale
# 需要导入模块: from ubuntutweak.conf import GconfSetting [as 别名]
# 或者: from ubuntutweak.conf.GconfSetting import get_value [as 别名]
class GconfScale(gtk.HScale):
def __init__(self, key=None, min=None, max=None, digits=0, reversed=False):
gtk.HScale.__init__(self)
if digits > 0:
self.__setting = GconfSetting(key=key, type=float)
else:
self.__setting = GconfSetting(key=key, type=int)
if reversed:
self.__reversed = True
else:
self.__reversed = False
self.set_range(min, max)
self.set_digits(digits)
self.set_value_pos(gtk.POS_RIGHT)
self.connect("value-changed", self.on_value_changed)
if self.__reversed:
self.set_value(max - self.__setting.get_value())
else:
self.set_value(self.__setting.get_value())
def on_value_changed(self, widget, data=None):
if self.__reversed:
self.__setting.set_value(100 - widget.get_value())
else:
self.__setting.set_value(widget.get_value())
示例2: GconfEntry
# 需要导入模块: from ubuntutweak.conf import GconfSetting [as 别名]
# 或者: from ubuntutweak.conf.GconfSetting import get_value [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"))
示例3: GconfComboBox
# 需要导入模块: from ubuntutweak.conf import GconfSetting [as 别名]
# 或者: from ubuntutweak.conf.GconfSetting import get_value [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)
示例4: GconfCheckButton
# 需要导入模块: from ubuntutweak.conf import GconfSetting [as 别名]
# 或者: from ubuntutweak.conf.GconfSetting import get_value [as 别名]
class GconfCheckButton(gtk.CheckButton):
def __init__(self, label=None, key=None, default=None, tooltip=None):
super(GconfCheckButton, self).__init__()
self.__setting = GconfSetting(key=key, default=default, type=bool)
self.set_label(label)
self.set_active(self.__setting.get_value())
if tooltip:
self.set_tooltip_text(tooltip)
self.__setting.get_client().notify_add(key, self.value_changed)
self.connect('toggled', self.button_toggled)
def value_changed(self, client, id, entry, data=None):
self.set_active(self.__setting.get_value())
def button_toggled(self, widget, data=None):
self.__setting.set_value(self.get_active())
示例5: GconfSpinButton
# 需要导入模块: from ubuntutweak.conf import GconfSetting [as 别名]
# 或者: from ubuntutweak.conf.GconfSetting import get_value [as 别名]
class GconfSpinButton(gtk.SpinButton):
def __init__(self, key, min=0, max=0, step=0):
self.__setting = GconfSetting(key=key, type=int)
adjust = gtk.Adjustment(self.__setting.get_value(), min, max, step)
gtk.SpinButton.__init__(self, adjust)
self.connect('value-changed', self.on_value_changed)
def on_value_changed(self, widget):
self.__setting.set_value(widget.get_value())
示例6: GconfComboBox
# 需要导入模块: from ubuntutweak.conf import GconfSetting [as 别名]
# 或者: from ubuntutweak.conf.GconfSetting import get_value [as 别名]
def GconfComboBox(key=None, texts=None, values=None):
def value_changed_cb(widget, setting):
text = widget.get_active_text()
setting.get_client().set_value(setting.get_key(), setting.values[setting.texts.index(text)])
combobox = gtk.combo_box_new_text()
setting = GconfSetting(key=key)
setting.texts = texts
setting.values = values
for text in texts:
combobox.append_text(text)
if setting.get_value() in values:
combobox.set_active(values.index(setting.get_value()))
combobox.connect("changed", value_changed_cb, setting)
return combobox
示例7: ButtonView
# 需要导入模块: from ubuntutweak.conf import GconfSetting [as 别名]
# 或者: from ubuntutweak.conf.GconfSetting import get_value [as 别名]
class ButtonView(gtk.IconView):
(COLUMN_KEY,
COLUMN_LABEL,
) = range(2)
values = {
'menu': _('Menu'),
':': _('Title'),
'maximize': _('Maximize'),
'minimize': _('Minimize'),
'close': _('Close'),
'spacer': _('Spacer'),
}
def __init__(self):
gtk.IconView.__init__(self)
self.config = GconfSetting(key='/apps/metacity/general/button_layout')
model = self.__create_model()
self.set_model(model)
self.update_model()
self.set_text_column(self.COLUMN_LABEL)
self.set_reorderable(True)
self.set_orientation(gtk.ORIENTATION_HORIZONTAL)
self.connect('selection-changed', self.on_button_changed)
def __create_model(self):
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
return model
def update_model(self, default=None):
model = self.get_model()
model.clear()
value = default or self.config.get_value()
if value:
list = value.replace(':', ',:,').split(',')
else:
return model
for k in list:
k = k.strip()
iter = model.append()
if k in self.values:
model.set(iter,
self.COLUMN_KEY, k,
self.COLUMN_LABEL, self.values[k])
else:
continue
return model
def on_button_changed(self, widget, data=None):
model = widget.get_model()
value = ','.join([i[self.COLUMN_KEY] for i in model])
value = value.replace(',:', ':').replace(':,', ':')
self.config.set_value(value)
def add_spacer(self):
model = self.get_model()
iter = model.append()
model.set(iter,
self.COLUMN_KEY, 'spacer',
self.COLUMN_LABEL, self.values['spacer'])
self.on_button_changed(self)
def remove_spacer(self):
model = self.get_model()
for i, row in enumerate(model):
if row[self.COLUMN_KEY] == 'spacer':
del model[i, self.COLUMN_KEY]
break
self.on_button_changed(self)
def has_spacer(self):
model = self.get_model()
for i, row in enumerate(model):
if row[self.COLUMN_KEY] == 'spacer':
return True
return False