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


Python Gtk.ToggleButton方法代码示例

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


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

示例1: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToggleButton [as 别名]
def __init__(self, application, button, value=None):
		"""
		:param button: The button used for activation.
		:type button: :py:class:`Gtk.ToggleButton`
		:param application: The application instance which owns this object.
		:param value: The present datetime value (defaults to 00:00).
		:type value: :py:class:`datetime.time`
		"""
		self.popover = _TimeSelector(application)
		self.button = button
		self.application = application
		self._time_format = "{time.hour:02}:{time.minute:02}"
		self._hour_spin = self.popover.gobjects['spinbutton_hour']
		self._hour_spin.connect('value-changed', lambda _: self.button.set_label(self._time_format.format(time=self.time)))
		self._minute_spin = self.popover.gobjects['spinbutton_minute']
		self._minute_spin.connect('value-changed', lambda _: self.button.set_label(self._time_format.format(time=self.time)))
		self.time = value or datetime.time(0, 0)
		self.popover.popover.set_relative_to(self.button)
		self.popover.popover.connect('closed', lambda _: self.button.set_active(False))
		self.button.connect('toggled', self.signal_button_toggled) 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:22,代码来源:managers.py

示例2: create_button

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToggleButton [as 别名]
def create_button(toggle, font_size, icon_code, release_callback=None, *additional_parameters):
    if toggle:
        button = Gtk.ToggleButton()
    else:
        button = Gtk.Button()

    button.set_relief(Gtk.ReliefStyle.NONE)
    Gtk.Widget.set_focus_on_click(button, True)
    button.set_size_request(width=constants.GRID_SIZE*3, height=-1)

    label = Gtk.Label()
    set_label_markup(label, icon_code, is_icon=True, size=font_size)
    button.add(label)

    if release_callback:
        button.connect('released', release_callback, *additional_parameters)

    return button 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:20,代码来源:states_editor.py

示例3: _update

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToggleButton [as 别名]
def _update(self, *a):
		for button in self.get_scrolled_children():
			self.remove(button)

		paths = list(self.get_paths())
		for path, label in zip(paths, shortest_unique_names(paths)):
			button = Gtk.ToggleButton(label=label, use_underline=False)
			button.set_tooltip_text(path.name)
			button.get_child().set_ellipsize(Pango.EllipsizeMode.MIDDLE)
			button.zim_path = path
			button.connect('clicked', self.on_button_clicked)
			button.connect('popup-menu', self.on_button_popup_menu)
			button.connect('button-release-event', self.on_button_release_event)
			button.connect('drag-data-get', self.on_drag_data_get)
			button.drag_source_set(
				Gdk.ModifierType.BUTTON1_MASK,
				(Gtk.TargetEntry.new(*INTERNAL_PAGELIST_TARGET),),
				Gdk.DragAction.LINK
			)
			button.show_all()
			self.add(button)

		if self.page is not None:
			self._select(self.page) 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:26,代码来源:pathbar.py

示例4: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToggleButton [as 别名]
def __init__(self, icon_name, tooltip):
        Gtk.ToggleButton.__init__(self)
        HeaderBarBtn.__init__(self, icon_name, tooltip) 
开发者ID:bilelmoussaoui,项目名称:Authenticator,代码行数:5,代码来源:headerbar.py

示例5: _build_header_bar

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToggleButton [as 别名]
def _build_header_bar(self):
        """Setup window headerbar."""
        # Header bar
        headerbar = Gtk.HeaderBar()
        headerbar_container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                                      spacing=3)

        title = Gtk.Label()
        title.set_text(_("Icon Chooser"))
        title.get_style_context().add_class("title")
        headerbar_container.pack_start(title, False, False, 0)

        subtitle = Gtk.Label()
        subtitle.get_style_context().add_class("subtitle")
        subtitle_text = ", ".join(self._folders)
        subtitle.set_text(subtitle_text)
        subtitle.set_ellipsize(Pango.EllipsizeMode.END)
        subtitle.set_tooltip_text(subtitle_text)
        subtitle.props.max_width_chars = 30
        headerbar_container.pack_start(subtitle, False, False, 0)

        headerbar.set_custom_title(headerbar_container)
        headerbar.set_show_close_button(False)

        # Search Button
        self._search_btn = Gtk.ToggleButton()
        search_icn = Gio.ThemedIcon(name="system-search-symbolic")
        search_img = Gtk.Image.new_from_gicon(search_icn, Gtk.IconSize.BUTTON)
        self._search_btn.set_image(search_img)

        # Cancel Button
        close_button = Gtk.Button()
        close_button.set_label(_("Close"))
        close_button.connect("clicked", self._close_window)

        headerbar.pack_start(close_button)
        headerbar.pack_end(self._search_btn)
        self.set_titlebar(headerbar) 
开发者ID:bilelmoussaoui,项目名称:nautilus-folder-icons,代码行数:40,代码来源:widgets.py

示例6: _on_popover_mouse_over

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToggleButton [as 别名]
def _on_popover_mouse_over(self, widget, eventcrossing):
        if eventcrossing.type == Gdk.EventType.ENTER_NOTIFY:
            if self._popover_inprogress == 0:
                self._popover_inprogress = 1
                print("enter1")
            else:
                self._popover_inprogress = 2
                print("enter2")
            self._popover_inprogress_count = 0

            if type(widget) is Gtk.ToggleButton:
                print("here")
                if widget.get_active():
                    print(self._parent_container)
                    self._parent_container.show_all()
        else:
            print("exit")
            self._popover_inprogress = 3

        def delayed(*args):
            if self._popover_inprogress == 3:
                self._popover_inprogress_count += 1

                if self._popover_inprogress_count < 5:
                    return True

                self._parent_container.hide()
                self._popover_inprogress = 0
                print("exit timeout")
                return False
            else:
                return True

        if self._popover_inprogress == 1:
            print("adding timeout")
            self._popover_inprogress = 2
            GLib.timeout_add(100, delayed) 
开发者ID:fossfreedom,项目名称:alternative-toolbar,代码行数:39,代码来源:alttoolbar_repeat.py

示例7: connect_actionable

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToggleButton [as 别名]
def connect_actionable(self, instance, actionable):
		'''Connect a C{Gtk.ToggleAction} or C{Gtk.ToggleButton} to this action.
		@param instance: the object instance that owns this action
		@param actionable: proxy object, needs to have methods
		C{set_active(is_active)} and C{get_active()} and a signal
		'C{toggled}'.
		'''
		actionable.set_active(self._state.get(instance, self._init))
		actionable.connect('toggled', self.do_activate, instance)

		if not instance in self._proxies:
			self._proxies[instance] = []
		self._proxies[instance].append(actionable) 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:15,代码来源:actions.py

示例8: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToggleButton [as 别名]
def __init__(self, label, menu, status_bar_style=False):
		'''Constructor

		@param label: the label to show on the button (string or C{Gtk.Label})
		@param menu: the menu to show on button click
		@param status_bar_style: when C{True} all padding and border
		is removed so the button fits in the status bar
		'''
		GObject.GObject.__init__(self)
		if isinstance(label, str):
			self.label = Gtk.Label()
			self.label.set_markup_with_mnemonic(label)
		else:
			assert isinstance(label, Gtk.Label)
			self.label = label

		self.menu = menu
		self.button = Gtk.ToggleButton()
		if status_bar_style:
			button_set_statusbar_style(self.button)

		arrow = Gtk.Arrow(Gtk.ArrowType.UP, Gtk.ShadowType.NONE)
		widget = Gtk.HBox(spacing=3)
		widget.pack_start(self.label, False, True, 0)
		widget.pack_start(arrow, False, True, 0)


		self.button.add(widget)
		# We need to wrap stuff in an eventbox in order to get the Gdk.Window
		# which we need to get coordinates when positioning the menu
		self.eventbox = Gtk.EventBox()
		self.eventbox.add(self.button)
		self.add(self.eventbox)

		self.button.connect_object(
			'button-press-event', self.__class__.popup_menu, self)
		self._clicked_signal = self.button.connect_object(
			'clicked', self.__class__.popup_menu, self)

		# TODO reduce size of toggle-button - see gedit-status-combo for example
		# TODO looks like other statusbar items resize on toggle button 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:43,代码来源:widgets.py

示例9: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToggleButton [as 别名]
def __init__(self, indextag):
		Gtk.ToggleButton.__init__(self, indextag.name, use_underline=False)
		self.set_relief(Gtk.ReliefStyle.NONE)
		self.indextag = indextag

		def update_label(self):
			# Make button text bold when active
			label = self.get_child()
			if self.get_active():
				label.set_markup('<b>' + label.get_text() + '</b>')
			else:
				label.set_text(label.get_text())
					# get_text() gives string without markup

		self.connect_after('toggled', update_label) 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:17,代码来源:tags.py

示例10: _reload_bar

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToggleButton [as 别名]
def _reload_bar(self):
		'''Reload bar with bookmarks.'''
		for button in self.scrolledbox.get_scrolled_children():
			self.scrolledbox.remove(button)

		page = self._get_page()
		if page:
			pagename = page.name
		else:
			pagename = None

		for path in self.paths:
			if path in self.paths_names:
				name = self.paths_names[path]
			elif not self.uistate['show_full_page_name']:
				name = self._get_short_page_name(path)
			else:
				name = path
			button = Gtk.ToggleButton(label=name, use_underline=False)
			button.set_tooltip_text(path)
			button.get_child().set_ellipsize(Pango.EllipsizeMode.MIDDLE)
			button.zim_path = path
			if path == pagename:
				button.set_active(True)

			button.connect('clicked', self.on_bookmark_clicked)
			button.connect('button-release-event', self.do_bookmarks_popup_menu)
			button.show()
			self.scrolledbox.add(button)

		# 'Disable' plus_button if max bookmarks is reached.
		if self.max_bookmarks and (len(self.paths) >= self.max_bookmarks):
			self.plus_button.change_state(False)
		else:
			self.plus_button.change_state(True)

		# Update config files.
		if self.save_flag:
			self.uistate['bookmarks'] = self.paths
			self.uistate['bookmarks_names'] = self.paths_names 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:42,代码来源:bookmarksbar.py

示例11: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToggleButton [as 别名]
def __init__(self):
        super(SourceEditorView, self).__init__(name='SOURCE EDITOR', language='python',
                                               editor_style="SOURCE_EDITOR_STYLE", run_with_spacer=False)

        try:
            if isinstance(self.textview, GtkSource.View):
                self.textview.set_tab_width(4)
                self.textview.set_insert_spaces_instead_of_tabs(True)
                self.textview.set_show_line_numbers(True)
                self.textview.set_auto_indent(True)
                self.textview.set_highlight_current_line(True)
        except NameError:
            pass
        hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
        hbox.get_style_context().add_class("widget-toolbar")
        pylint_check_button = Gtk.CheckButton(label="Validate")
        Gtk.Widget.set_focus_on_click(pylint_check_button, True)
        pylint_check_button.set_border_width(constants.BUTTON_BORDER_WIDTH)
        pylint_check_button.get_style_context().add_class("secondary")

        open_external_button = Gtk.ToggleButton(label="Open externally")
        Gtk.Widget.set_focus_on_click(open_external_button, True)
        open_external_button.set_border_width(constants.BUTTON_BORDER_WIDTH)

        apply_button = Gtk.Button(label="Apply")
        Gtk.Widget.set_focus_on_click(apply_button, True)
        apply_button.set_border_width(constants.BUTTON_BORDER_WIDTH)

        cancel_button = Gtk.Button(label="Reset")
        Gtk.Widget.set_focus_on_click(cancel_button, True)
        cancel_button.set_border_width(constants.BUTTON_BORDER_WIDTH)

        hbox.pack_start(pylint_check_button, False, False, 0)
        hbox.pack_end(open_external_button, False, True, 0)
        hbox.pack_end(cancel_button, False, True, 0)
        hbox.pack_end(apply_button, False, True, 0)

        label.ellipsize_labels_recursively(hbox)

        self['editor_frame'].pack_start(hbox, expand=False, fill=True, padding=0)
        self['pylint_check_button'] = pylint_check_button
        self['apply_button'] = apply_button
        self['open_external_button'] = open_external_button
        self['cancel_button'] = cancel_button

        # TODO find the properties where the the next three values can be read from
        # value is an assumption because its respective property is not found till now
        self.line_numbers_width = 35
        # this value is from the main window glade file and respective right_bar_container width request
        self.tab_width = 53
        # value is an assumption because its respective property is not found till now
        self.source_view_character_size = 8
        # observe key press events to adapt pane position
        # Note: -> changed is not used because it is creating glib segfaults
        if self.spacer_frame is not None:
            self.textview.connect("key-press-event", self.on_text_view_event) 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:58,代码来源:source_editor.py


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