本文整理汇总了Python中gi.repository.Gio.Settings.set_string方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.set_string方法的具体用法?Python Settings.set_string怎么用?Python Settings.set_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gio.Settings
的用法示例。
在下文中一共展示了Settings.set_string方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _onComboChanged
# 需要导入模块: from gi.repository.Gio import Settings [as 别名]
# 或者: from gi.repository.Gio.Settings import set_string [as 别名]
def _onComboChanged(self, model, path, iter):
"""
Callback for row changes. Copies the changed key combos over to gsettings.
@param model: The model that emitted the signal. Should be this class instance.
@type model: L{gtk.TreeModel}
@param path: The path of the row that has changed.
@type path: tuple
@param iter: The iter of the row that has changed.
@type iter: L{gtk.TreeIter}
"""
if not model[iter][COL_COMPONENT] or not model[iter][COL_DESC]:
return
gspath = self._getComboGSettingsPath(model[iter][COL_COMPONENT], model[iter][COL_DESC])
gsettings = GSettings(schema=HOTKEYS_GSCHEMA, path=gspath)
combo_name = gtk.accelerator_name(model[iter][COL_KEYPRESS], gdk.ModifierType(model[iter][COL_MOD]))
key = gsettings.get_string("hotkey-combo")
if key != combo_name and key != "/":
gsettings.set_string("hotkey-combo", combo_name)
示例2: _HighlighterView
# 需要导入模块: from gi.repository.Gio import Settings [as 别名]
# 或者: from gi.repository.Gio.Settings import set_string [as 别名]
class _HighlighterView(gtk.Alignment):
'''
A container widget with the settings for the highlighter.
'''
def __init__(self):
gtk.Alignment.__init__(self)
self.set_padding(12, 12, 18, 12)
self.gsettings = GSettings(schema='org.a11y.Accerciser')
self._buildUI()
def _buildUI(self):
'''
Programatically build the UI.
'''
table = gtk.Table(3, 2)
table.set_col_spacings(6)
self.add(table)
labels = [None, None, None]
controls = [None, None, None]
labels[0] = gtk.Label(_('Highlight duration:'))
controls[0] = gtk.SpinButton()
controls[0].set_range(0.01, 5)
controls[0].set_digits(2)
controls[0].set_value(self.gsettings.get_double('highlight-duration'))
controls[0].set_increments(0.01, 0.1)
controls[0].connect('value-changed', self._onDurationChanged)
labels[1] = gtk.Label(_('Border color:'))
controls[1] = self._ColorButton(node.BORDER_COLOR, node.BORDER_ALPHA)
controls[1].connect('color-set', self._onColorSet, 'highlight-border')
controls[1].set_tooltip_text(_('The border color of the highlight box'))
labels[2] = gtk.Label(_('Fill color:'))
controls[2] = self._ColorButton(node.FILL_COLOR, node.FILL_ALPHA)
controls[2].connect('color-set', self._onColorSet, 'highlight-fill')
controls[2].set_tooltip_text(_('The fill color of the highlight box'))
for label, control, row in zip(labels, controls, range(3)):
label.set_alignment(0, 0.5)
table.attach(label, 0, 1, row, row + 1, gtk.AttachOptions.FILL)
table.attach(control, 1, 2, row, row + 1, gtk.AttachOptions.FILL)
for label, control in zip([x.get_accessible() for x in labels],
[x.get_accessible() for x in controls]):
label.add_relationship(atk.RelationType.LABEL_FOR, control)
control.add_relationship(atk.RelationType.LABELLED_BY, label)
def _onDurationChanged(self, spin_button):
'''
Callback for the duration spin button. Update key and the global variable
in the L{node} module.
@param spin_button: The spin button that emitted the value-changed signal.
@type spin_button: gtk.SpinButton
'''
node.HL_DURATION = int(spin_button.get_value()*1000)
self.gsettings.set_double('highlight-duration',
spin_button.get_value())
def _onColorSet(self, color_button, key):
'''
Callback for a color button. Update gsettings and the global variables
in the L{node} module.
@param color_button: The color button that emitted the color-set signal.
@type color_button: l{_HighlighterView._ColorButton}
@param key: the key name suffix for this color setting.
@type key: string
'''
if 'fill' in key:
node.FILL_COLOR = color_button.get_rgb_string()
node.FILL_ALPHA = color_button.get_alpha_float()
else:
node.BORDER_COLOR = color_button.get_rgb_string()
node.BORDER_ALPHA = color_button.get_alpha_float()
self.gsettings.set_string(key, color_button.get_rgba_string())
class _ColorButton(gtk.ColorButton):
'''
ColorButton derivative with useful methods for us.
'''
def __init__(self, color, alpha):
color = gdk.color_parse(color)
gtk.ColorButton.__init__(self)
self.set_use_alpha(True)
self.set_alpha(int(alpha*0xffff))
self.set_color(color)
def get_rgba_string(self):
'''
Get the current color and alpha in string format.
@return: String in the format of #rrggbbaa.
@rtype: string.
'''
color = self.get_color()
color_val = 0
color_val |= color.red >> 8 << 24
color_val |= color.green >> 8 << 16
color_val |= color.blue >> 8 << 8
#.........这里部分代码省略.........