Python gi.repository.Gtk 模块,SpinButton() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用gi.repository.Gtk.SpinButton()

项目:ibus-typing-booster    作者:mike-fabian    | 项目源码 | 文件源码
def on_fontsize_spin_button_grab_focus( # pylint: disable=no-self-use
            self, spin_button):
        '''
        Signal handler called when the spin button to change
        the font size grabs focus

        :param spin_button: The spin button to change the font size
        :type spin_button: Gtk.SpinButton object
        '''
        if _ARGS.debug:
            sys.stdout.write(
                'on_fontsize_spin_button_grab_focus() spin_button = %s\n'
                %repr(spin_button))
        spin_button.grab_focus_without_selecting()
        # The default signal handler would again select the contents
        # of the search entry. Therefore, we must prevent the default
        # signal handler from running:
        GObject.signal_stop_emission_by_name(spin_button, 'grab-focus')
        return True
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self, exname, name, adj, climb_rate=1, digits=1):
        Gtk.SpinButton.__init__(self)
        cfg.ConfigUtils.__init__(self, exname)
        self.set_adjustment(adj)
        self.m_name = name
        self.set_digits(0)
        self.show()
        self.set_alignment(1)
        self.set_value(self.get_float(self.m_name))
        if self.get_value() != self.get_float(self.m_name):
            self.set_float(self.m_name, self.get_value())
        self.connect('value-changed', self.on_changed)
        self._watch_id = self.add_watch(self.m_name, self._watch_cb)
        self.m_stop_watch = 0
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def _watch_cb(self, name):
        if not self.m_stop_watch:
            Gtk.SpinButton.set_value(self, self.get_float(name))
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def set_value(self, value):
        Gtk.SpinButton.set_value(self, value)
        self.set_float(self.m_name, value)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def tSpinButton(table, x1, x2, y1, y2,
                value, lower, upper, step_incr=1, page_incr=10, callback=None):
    adj = Gtk.Adjustment(value, lower, upper, step_incr, page_incr)
    spin = Gtk.SpinButton(adj, digits=0)
    if callback:
        spin.connect('value-changed', callback)
    table.attach(spin, x1, x2, y1, y2)
    return spin
项目:draobpilc    作者:awamper    | 项目源码 | 文件源码
def add_spin(self, label, key, adjust_props={}, spin_props={}, type_=int):
        def on_changed(spin):
            value = None

            if type_ is int:
                value = spin.get_value_as_int()
            else:
                value = spin.get_value()

            self._settings[key] = value

        adjust_default = {
            'lower': 0,
            'upper': 100,
            'step_increment': 1
        }
        adjustment = Gtk.Adjustment()
        adjustment.set_lower(
            adjust_props.get('lower', adjust_default['lower'])
        )
        adjustment.set_upper(
            adjust_props.get('upper', adjust_default['upper'])
        )
        adjustment.set_step_increment(
            adjust_props.get('step_increment', adjust_default['step_increment'])
        )


        spin_button = Gtk.SpinButton()
        spin_button.set_adjustment(adjustment)
        spin_button.set_numeric(True)
        spin_button.set_snap_to_ticks(True)
        spin_button.set_value(self._settings[key])
        spin_button.connect('value-changed', on_changed)

        if type_ is float:
            spin_button.set_digits(2)

        return self.add_row(label, spin_button, True)
项目:lightdm-settings    作者:linuxmint    | 项目源码 | 文件源码
def __init__(self, keyfile, settings, key, min_value, max_value):
        self.key = key
        self.keyfile = keyfile
        try:
            self.value = keyfile.get_integer(GROUP_NAME, key)
        except:
            self.value = settings.get_int(key)
        Gtk.SpinButton.__init__(self)
        adjustment = Gtk.Adjustment(self.value, min_value, max_value, 1, 10, 0)
        self.set_adjustment(adjustment)
        self.set_value(self.value)
        self.connect("value-changed", self.on_value_changed)
项目:funky    作者:giannitedesco    | 项目源码 | 文件源码
def __init__(self, name, count):
        super(ResourceRow, self).__init__()

        hbox = Gtk.Box(orientation = Gtk.Orientation.HORIZONTAL,
                    spacing = 5)

        self.name = Gtk.Label(xalign = 0)
        self.name.set_markup('<b>%s</b>'%name)


        self.c = Gtk.SpinButton()
        self.c.set_numeric(True)
        self.c.set_increments(1, 1)
        self.c.set_editable(False)
        self.c.set_can_focus(False)

        self.p = Gtk.SpinButton()
        self.p.set_numeric(True)
        self.p.set_increments(1, 1)
        self.p.set_can_focus(False)
        self.p.set_value(0)

        hbox.pack_start(self.name, True, True, 5)
        hbox.pack_start(self.c, False, True, 5)
        hbox.pack_start(self.p, False, True, 5)
        self.add(hbox)

        self.set_can_focus(False)

        self.update_count(count)