当前位置: 首页>>代码示例>>Python>>正文


Python GconfSetting.set_value方法代码示例

本文整理汇总了Python中ubuntutweak.conf.GconfSetting.set_value方法的典型用法代码示例。如果您正苦于以下问题:Python GconfSetting.set_value方法的具体用法?Python GconfSetting.set_value怎么用?Python GconfSetting.set_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ubuntutweak.conf.GconfSetting的用法示例。


在下文中一共展示了GconfSetting.set_value方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GconfScale

# 需要导入模块: from ubuntutweak.conf import GconfSetting [as 别名]
# 或者: from ubuntutweak.conf.GconfSetting import set_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())
开发者ID:jonolumb,项目名称:ubuntu-tweak,代码行数:29,代码来源:widgets.py

示例2: GconfSpinButton

# 需要导入模块: from ubuntutweak.conf import GconfSetting [as 别名]
# 或者: from ubuntutweak.conf.GconfSetting import set_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())
开发者ID:jonolumb,项目名称:ubuntu-tweak,代码行数:12,代码来源:widgets.py

示例3: GconfCheckButton

# 需要导入模块: from ubuntutweak.conf import GconfSetting [as 别名]
# 或者: from ubuntutweak.conf.GconfSetting import set_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())
开发者ID:jonolumb,项目名称:ubuntu-tweak,代码行数:20,代码来源:widgets.py

示例4: ButtonView

# 需要导入模块: from ubuntutweak.conf import GconfSetting [as 别名]
# 或者: from ubuntutweak.conf.GconfSetting import set_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
开发者ID:actiononmail,项目名称:ubuntu-tweak,代码行数:84,代码来源:metacity.py


注:本文中的ubuntutweak.conf.GconfSetting.set_value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。