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


Python Gtk.SpinButton方法代码示例

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


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

示例1: display_value

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SpinButton [as 别名]
def display_value(self, key, w):
		"""
		Sets value on UI element for single key. May be overridden
		by subclass to handle special values.
		"""
		if isinstance(w, Gtk.SpinButton):
			w.get_adjustment().set_value(ints(self.get_value(strip_v(key))))
		elif isinstance(w, Gtk.Entry):
			w.set_text(unicode(self.get_value(strip_v(key))))
		elif isinstance(w, Gtk.ComboBox):
			val = self.get_value(strip_v(key))
			m = w.get_model()
			for i in xrange(0, len(m)):
				if str(val) == str(m[i][0]).strip():
					w.set_active(i)
					break
			else:
				w.set_active(0)
		elif isinstance(w, Gtk.CheckButton):
			w.set_active(self.get_value(strip_v(key)))
		else:
			log.warning("display_value: %s class cannot handle widget %s, key %s", self.__class__.__name__, w, key)
			if not w is None: w.set_sensitive(False) 
开发者ID:kozec,项目名称:syncthing-gtk,代码行数:25,代码来源:editordialog.py

示例2: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SpinButton [as 别名]
def __init__(self, pageview, notebook, page, screenshot_command):
		Dialog.__init__(self, pageview, _('Insert Screenshot'))  # T: dialog title
		self.pageview = pageview
		self.screenshot_command = screenshot_command
		if ScreenshotPicker.has_select_cmd(self.screenshot_command):
			self.screen_radio = Gtk.RadioButton.new_with_mnemonic_from_widget(None,
												_('Capture whole screen'))  # T: option in 'insert screenshot' dialog
			self.select_radio = Gtk.RadioButton.new_with_mnemonic_from_widget(self.screen_radio,
												_('Select window or region'))  # T: option in 'insert screenshot' dialog
			self.vbox.add(self.screen_radio)
			self.vbox.add(self.select_radio)

		self.notebook = notebook
		self.page = page
		if ScreenshotPicker.has_delay_cmd(self.screenshot_command):
			hbox = Gtk.HBox()
			self.vbox.add(hbox)
			hbox.add(Gtk.Label(label=_('Delay') + ': '))  # T: input in 'insert screenshot' dialog
			self.time_spin = Gtk.SpinButton()
			self.time_spin.set_range(0, 99)
			self.time_spin.set_increments(1, 5)
			self.time_spin.set_value(0)
			hbox.add(self.time_spin)
			hbox.add(Gtk.Label(label=' ' + _('seconds')))  # T: label behind timer 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:26,代码来源:screenshot.py

示例3: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SpinButton [as 别名]
def __init__(
        self,
        text,
        option_name,
        default=0,
        min_value=0,
        max_value=1000,
        increment=1,
        **kwargs
    ):
        Option.__init__(self, text, option_name, **kwargs)

        value = Option.config.read(option_name, default=default)
        value = int(value)

        self.spin_button = Gtk.SpinButton()
        adjustment = Gtk.Adjustment(value, min_value, max_value, increment, 10, 0)
        self.spin_button.set_adjustment(adjustment)
        self.spin_button.set_value(value)
        self.spin_button.set_numeric(True)
        self.spin_button.set_update_policy(Gtk.SpinButtonUpdatePolicy.IF_VALID)

        self.pack_start(self.spin_button, True, True, 0) 
开发者ID:jendrikseipp,项目名称:rednotebook,代码行数:25,代码来源:options.py

示例4: get_widget

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SpinButton [as 别名]
def get_widget(self, _, value):
		widget = Gtk.SpinButton()
		widget.set_hexpand(True)
		widget.set_adjustment(self.adjustment)
		widget.set_numeric(True)
		widget.set_update_policy(Gtk.SpinButtonUpdatePolicy.IF_VALID)
		self.set_widget_value(widget, value)
		return widget 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:10,代码来源:plugins.py

示例5: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SpinButton [as 别名]
def __init__(self, default, min_value, max_value, step=20, page=40):
        Gtk.SpinButton.__init__(self)
        self.set_digits(0)
        self.set_numeric(False)
        self.set_range(min_value, max_value)
        self.set_value(default)
        self.set_increments(step, page) 
开发者ID:ImEditor,项目名称:ImEditor,代码行数:9,代码来源:tools.py

示例6: _populate_gtk

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SpinButton [as 别名]
def _populate_gtk(self, width):
        """Creates the gtk widgets

        @param width: the width of the Gtk.Label object
        """
        period_label = Gtk.Label(label=_("Check for new tasks every"))
        period_label.set_alignment(xalign=0, yalign=0.5)
        period_label.set_line_wrap(True)
        period_label.set_size_request(width=width, height=-1)
        self.pack_start(period_label, False, True, 0)
        align = Gtk.Alignment.new(0, 0.5, 1, 0)
        align.set_padding(0, 0, 10, 0)
        self.pack_start(align, False, True, 0)
        period = self.backend.get_parameters()['period']
        self.adjustment = Gtk.Adjustment(value=period,
                                         lower=1,
                                         upper=120,
                                         step_incr=1,
                                         page_incr=0,
                                         page_size=0)
        self.period_spin = Gtk.SpinButton(adjustment=self.adjustment,
                                          climb_rate=0.3,
                                          digits=0)
        self.minutes_label = Gtk.Label()
        self.update_minutes_label()
        self.minutes_label.set_alignment(xalign=0, yalign=0.5)
        self.pack_start(self.minutes_label, False, True, 0)
        align.add(self.period_spin)
        self.show_all() 
开发者ID:getting-things-gnome,项目名称:gtg,代码行数:31,代码来源:period.py

示例7: store_value

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SpinButton [as 别名]
def store_value(self, key, w):
		"""
		Loads single value from UI element to self.values dict. May be
		overriden by subclass to handle special values.
		"""
		if isinstance(w, Gtk.SpinButton):
			self.set_value(strip_v(key), int(w.get_adjustment().get_value()))
		elif isinstance(w, Gtk.Entry):
			self.set_value(strip_v(key), w.get_text().decode("utf-8"))
		elif isinstance(w, Gtk.CheckButton):
			self.set_value(strip_v(key), w.get_active())
		elif isinstance(w, Gtk.ComboBox):
			self.set_value(strip_v(key), str(w.get_model()[w.get_active()][0]).strip())
		# else nothing, unknown widget class cannot be read 
开发者ID:kozec,项目名称:syncthing-gtk,代码行数:16,代码来源:editordialog.py

示例8: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SpinButton [as 别名]
def __init__(self, min=0, max=100, value=0, step=1, page_step=5):
		adjustment = Gtk.Adjustment(value=value, lower=min, upper=max, step_increment=step, page_increment=page_step, page_size=0)
		Gtk.SpinButton.__init__(self, adjustment=adjustment) 
开发者ID:AXeL-dev,项目名称:Dindo-Bot,代码行数:5,代码来源:custom.py

示例9: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SpinButton [as 别名]
def __init__(  # pylint: disable=too-many-arguments
            self,
            display_name, key,
            callback,
            init_value,
            min_value, max_value,
            step_increment,
            page_increment,
            page_size
    ):

        adjustment = Gtk.Adjustment(
            value=init_value,
            lower=min_value,
            upper=max_value,
            step_increment=step_increment,
            page_increment=page_increment,
            page_size=page_size
        )
        spinbutton = Gtk.SpinButton(
            adjustment=adjustment,
        )
        spinbutton.set_numeric(True)
        spinbutton.set_update_policy(Gtk.SpinButtonUpdatePolicy.IF_VALID)

        super().__init__(
            display_name=display_name,
            key=key,
            callback=callback,
            value_widget=spinbutton
        ) 
开发者ID:themix-project,项目名称:oomox,代码行数:33,代码来源:colors_list.py

示例10: update_frame_position

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SpinButton [as 别名]
def update_frame_position(self, widget, user_data):
        """ Callback to preview the frame alignment, called from the Gtk.SpinButton.

        Args:
            widget (:class:`~Gtk.SpinButton`): The button updating the slide alignment in the drawing area widget
            user_data (`str`): The property being set, either the x or y alignment (resp. xalign and yalign).
        """
        self.c_frame.set_property(user_data, widget.get_value()) 
开发者ID:Cimbali,项目名称:pympress,代码行数:10,代码来源:ui.py

示例11: adjust_frame_position

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SpinButton [as 别名]
def adjust_frame_position(self, *args):
        """ Select how to align the frame on screen.
        """
        win_aspect_ratio = float(self.c_win.get_allocated_width()) / self.c_win.get_allocated_height()

        if win_aspect_ratio <= float(self.c_frame.get_property("ratio")):
            prop = "yalign"
        else:
            prop = "xalign"

        val = self.c_frame.get_property(prop)

        button = Gtk.SpinButton()
        button.set_adjustment(Gtk.Adjustment(lower=0.0, upper=1.0, step_increment=0.01))
        button.set_digits(2)
        button.set_value(val)
        button.connect("value-changed", self.update_frame_position, prop)

        popup = Gtk.Dialog(title = _("Adjust alignment of slides in projector screen"), transient_for = self.p_win)
        popup.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)

        box = popup.get_content_area()
        box.add(button)
        popup.show_all()
        response = popup.run()
        popup.destroy()

        # revert if we cancelled
        if response == Gtk.ResponseType.CANCEL:
            self.c_frame.set_property(prop, val)
        else:
            self.config.set('content', prop, str(button.get_value())) 
开发者ID:Cimbali,项目名称:pympress,代码行数:34,代码来源:ui.py

示例12: more_actions

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SpinButton [as 别名]
def more_actions(self, event, name):
        """ Implement directions (left/right/home/end) keystrokes.

        Otherwise pass on to :func:`~Gtk.SpinButton.do_key_press_event()`.
        """
        modified = event.get_state() & Gdk.ModifierType.CONTROL_MASK or event.get_state() & Gdk.ModifierType.SHIFT_MASK

        if name == 'home':
            self.spin_cur.set_value(1)
        elif name == 'end':
            self.spin_cur.set_value(self.max_page_number)
        elif modified and name == 'up':
            cur_page = int(self.spin_cur.get_value()) - 1
            self.spin_cur.set_value(1 + self.label_before(cur_page))
        elif modified and name == 'down':
            cur_page = int(self.spin_cur.get_value()) - 1
            self.spin_cur.set_value(1 + self.label_after(cur_page))
        elif name == 'up':
            self.spin_cur.set_value(self.spin_cur.get_value() - 1)
        elif name == 'down':
            self.spin_cur.set_value(self.spin_cur.get_value() + 1)
        elif self.page_labels and self.edit_label.is_focus():
            return Gtk.Entry.do_key_press_event(self.edit_label, event)
        else:
            return Gtk.SpinButton.do_key_press_event(self.spin_cur, event)

        return True 
开发者ID:Cimbali,项目名称:pympress,代码行数:29,代码来源:editable_label.py

示例13: on_scroll

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SpinButton [as 别名]
def on_scroll(self, widget, event):
        """ Scroll event. Pass it on to the spin button if we're currently editing the page number.

        Args:
            widget (:class:`~Gtk.Widget`):  the widget which has received the event.
            event (:class:`~Gdk.Event`):  the GTK event.

        Returns:
            `bool`: whether the event was consumed
        """
        if not self.editing:
            return False
        else:
            # flip scroll direction to get scroll down advancing slides
            if self.invert_scroll and event.direction == Gdk.ScrollDirection.DOWN:
                event.direction = Gdk.ScrollDirection.UP
            elif self.invert_scroll and event.direction == Gdk.ScrollDirection.UP:
                event.direction = Gdk.ScrollDirection.DOWN

            # Manually get destination slide if we're editing labels
            if self.edit_label.is_focus():
                cur_page = int(self.spin_cur.get_value()) - 1
                if event.direction == Gdk.ScrollDirection.DOWN:
                    self.spin_cur.set_value(1 + self.label_before(cur_page))
                elif event.direction == Gdk.ScrollDirection.UP:
                    self.spin_cur.set_value(1 + self.label_after(cur_page))

            # Otherwise let the spinner do its job
            else:
                return Gtk.SpinButton.do_scroll_event(self.spin_cur, event) 
开发者ID:Cimbali,项目名称:pympress,代码行数:32,代码来源:editable_label.py

示例14: on_discount_clicked

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SpinButton [as 别名]
def on_discount_clicked(self, button):
        dialog = Gtk.Dialog("Discount percentage",
                            self.builder.get_object('general'),
                            Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                             Gtk.STOCK_OK, Gtk.ResponseType.OK)
                            )
        adj = Gtk.Adjustment(0, 0, 100, 1, 1)
        spin = Gtk.SpinButton()
        spin.set_adjustment(adj)

        hbox = Gtk.HBox()
        hbox.pack_start(spin, True, True, 0)
        hbox.pack_start(Gtk.Label(' % ', True, True, 0), False, False, 0)
        hbox.show_all()

        dialog.vbox.pack_start(hbox, False, False, 0)

        result = dialog.run()
        if result == Gtk.ResponseType.OK:
            val = spin.get_value()
            total = self.total_credit_entry.get_float()
            discount = (val*total)/100
            self.discount_entry.set_text(str(discount))

        dialog.destroy() 
开发者ID:Jooyeshgar,项目名称:amir,代码行数:28,代码来源:automaticaccounting.py

示例15: add_adj

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SpinButton [as 别名]
def add_adj(self, label_text, key, adj):
		spinbtn = Gtk.SpinButton(adjustment=adj)
		spinbtn.set_value(self._settings.get_int(key))
		utilities_add_unit_to_spinbtn(spinbtn, 4, 'px')
		spinbtn.connect('value-changed', self.on_adj_changed, key)
		self.add_row(label_text, spinbtn) 
开发者ID:maoschanz,项目名称:drawing,代码行数:8,代码来源:preferences.py


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