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


Python Settings.get_double方法代码示例

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


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

示例1: __init__

# 需要导入模块: from gi.repository.Gio import Settings [as 别名]
# 或者: from gi.repository.Gio.Settings import get_double [as 别名]
class Zoomer:
    def __init__(self):
        self.incr = 0.1
        self._refreshSettings()

    def _refreshSettings(self):
        self.a11yAppPrefs = Settings('org.gnome.desktop.a11y.applications')
        self.magPrefs = Settings('org.gnome.desktop.a11y.magnifier')

    def zoomIn(self):
      mag_factor = self.magPrefs.get_double('mag-factor')
      self.magPrefs.set_double('mag-factor', mag_factor + self.incr)
      self.zoomOn()

    def zoomOut(self):
      mag_factor = self.magPrefs.get_double('mag-factor')
      self.magPrefs.set_double('mag-factor', mag_factor - self.incr)
      self.zoomOn()

    def zoomOff(self):
        self.a11yAppPrefs.set_boolean('screen-magnifier-enabled', False)

    def zoomOn(self):
        self.a11yAppPrefs.set_boolean('screen-magnifier-enabled', True)

    def isActive(self):
        return self.a11yAppPrefs.get_boolean('screen-magnifier-enabled')
开发者ID:timthelion,项目名称:gnome-shell-zoom-control-window,代码行数:29,代码来源:GnomeZoomSettings.py

示例2: GSettings

# 需要导入模块: from gi.repository.Gio import Settings [as 别名]
# 或者: from gi.repository.Gio.Settings import get_double [as 别名]
from gi.repository.Gio import Settings as GSettings

# from gi.repository import cairo
import cairo
import pyatspi
import string
from tools import Tools, parseColorString

MAX_BLINKS = 6

gsettings = GSettings(schema="org.a11y.Accerciser")
BORDER_COLOR, BORDER_ALPHA = parseColorString(gsettings.get_string("highlight-border"))

FILL_COLOR, FILL_ALPHA = parseColorString(gsettings.get_string("highlight-fill"))

HL_DURATION = int(gsettings.get_double("highlight-duration") * 1000)


class Bag(object):
    """
  Bag class for converting a dicionary to an object with attributes.
  """

    def __init__(self, **kwargs):
        self.__dict__.update(kwargs)

    def __str__(self):
        return ", ".join(vars(self).keys())


class Node(GObject.GObject, Tools):
开发者ID:GunioRobot,项目名称:accerciser-mirror,代码行数:33,代码来源:node.py

示例3: _HighlighterView

# 需要导入模块: from gi.repository.Gio import Settings [as 别名]
# 或者: from gi.repository.Gio.Settings import get_double [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
#.........这里部分代码省略.........
开发者ID:javihernandez,项目名称:accerciser,代码行数:103,代码来源:prefs_dialog.py


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