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


Python Gtk.Menu方法代码示例

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


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

示例1: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Menu [as 别名]
def __init__(self, image_path):
            Gtk.ImageMenuItem.__init__(self)
            self.get_style_context().add_class("KanoComboBox")
            self.set_use_underline(False)
            self.set_always_show_image(True)

            # set the given image
            pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_path)
            image = Gtk.Image.new_from_pixbuf(pixbuf)

            # put the image inside an alignment container for centering
            self.box = Gtk.Alignment()
            self.box.set_padding(0, 0, 0, pixbuf.get_width())
            self.box.add(image)

            # by default, a MenuItem has an AccelLabel widget as it's one and only child
            self.remove(self.get_child())
            self.add(self.box)

            # By overriding this signal we can stop the Menu
            # containing this item from being popped down
            self.connect("button-release-event", self.do_not_popdown_menu) 
开发者ID:KanoComputing,项目名称:kano-toolset,代码行数:24,代码来源:kano_combobox.py

示例2: on_treeview_button_release_event

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Menu [as 别名]
def on_treeview_button_release_event(self, widget, event):
        try:
            # define context menu
            popup = Gtk.Menu()
            kd_item = Gtk.MenuItem(_("Open with Kdenlive"))
            # selected row is already caught by on_treeview_selection_changed function
            kd_item.connect("activate", self.on_open_with_kdenlive, self.sel_folder)

            # don"t show menu item if there are no video files
            if self.sel_vid > 0 and cli.kd_supp is True:
                popup.append(kd_item)

            open_item = Gtk.MenuItem(_("Open folder"))
            open_item.connect("activate", self.on_open_folder, self.sel_folder)
            popup.append(open_item)
            popup.show_all()
            # only show on right click
            if event.button == 3:
                popup.popup(None, None, None, None, event.button, event.time)
                return True
        except AttributeError:
            # this error (missing variable self.sel_folder) is returned when clicking on title row
            # ignoring because there is nothing to happen on right click
            pass 
开发者ID:encarsia,项目名称:gpt,代码行数:26,代码来源:modules.py

示例3: gtk_menu_insert_by_path

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Menu [as 别名]
def gtk_menu_insert_by_path(menu, menu_path, menu_item):
	"""
	Add a new menu item into the existing menu at the path specified in
	*menu_path*.

	:param menu: The existing menu to add the new item to.
	:type menu: :py:class:`Gtk.Menu` :py:class:`Gtk.MenuBar`
	:param list menu_path: The labels of submenus to traverse to insert the new item.
	:param menu_item: The new menu item to insert.
	:type menu_item: :py:class:`Gtk.MenuItem`
	"""
	utilities.assert_arg_type(menu, (Gtk.Menu, Gtk.MenuBar), 1)
	utilities.assert_arg_type(menu_path, list, 2)
	utilities.assert_arg_type(menu_item, Gtk.MenuItem, 3)
	while len(menu_path):
		label = menu_path.pop(0)
		menu_cursor = gtk_menu_get_item_by_label(menu, label)
		if menu_cursor is None:
			raise ValueError('missing node labeled: ' + label)
		menu = menu_cursor.get_submenu()
	menu.append(menu_item) 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:23,代码来源:gui_utilities.py

示例4: _get_title_box

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Menu [as 别名]
def _get_title_box(self):
		menu = Gtk.Menu()
		menu.set_property('valign', Gtk.Align.START)
		menu_item = Gtk.MenuItem.new_with_label('Restore Default Options')
		menu_item.connect('activate', self.signal_activate_plugin_reset, self.plugin_klass)
		menu.append(menu_item)
		menu.show_all()
		self.menu = menu

		plugin_menu_button = Gtk.MenuButton()
		plugin_menu_button.set_property('direction', Gtk.ArrowType.LEFT)
		plugin_menu_button.set_popup(menu)

		title_box = Gtk.Box(Gtk.Orientation.HORIZONTAL, 3)
		title_box.pack_start(Gtk.Label(label=self.plugin_klass.title), False, True, 0)
		title_box.pack_end(plugin_menu_button, False, False, 0)
		return title_box 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:19,代码来源:configuration.py

示例5: get_popup_filter_menu

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Menu [as 别名]
def get_popup_filter_menu(self):
		# create filter menu and menuitems
		filter_menu = Gtk.Menu()
		menu_item_expired = Gtk.CheckMenuItem('Expired campaigns')
		menu_item_user = Gtk.CheckMenuItem('Your campaigns')
		menu_item_other = Gtk.CheckMenuItem('Other campaigns')
		self.filter_menu_items = {
			'expired_campaigns': menu_item_expired,
			'your_campaigns': menu_item_user,
			'other_campaigns': menu_item_other
		}
		# set up the menuitems and add it to the menubutton
		for menus in self.filter_menu_items:
			filter_menu.append(self.filter_menu_items[menus])
			self.filter_menu_items[menus].connect('toggled', self.signal_checkbutton_toggled)
			self.filter_menu_items[menus].show()
		self.filter_menu_items['expired_campaigns'].set_active(self.config['filter.campaign.expired'])
		self.filter_menu_items['your_campaigns'].set_active(self.config['filter.campaign.user'])
		self.filter_menu_items['other_campaigns'].set_active(self.config['filter.campaign.other_users'])
		self.gobjects['menubutton_filter'].set_popup(filter_menu)
		filter_menu.connect('destroy', self._save_filter) 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:23,代码来源:campaign_selection.py

示例6: get_popup_copy_submenu

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Menu [as 别名]
def get_popup_copy_submenu(self):
		"""
		Create a :py:class:`Gtk.Menu` with entries for copying cell data from
		the treeview.

		:return: The populated copy popup menu.
		:rtype: :py:class:`Gtk.Menu`
		"""
		copy_menu = Gtk.Menu.new()
		for column_title, store_id in self.column_titles.items():
			menu_item = Gtk.MenuItem.new_with_label(column_title)
			menu_item.connect('activate', self.signal_activate_popup_menu_copy, store_id)
			copy_menu.append(menu_item)
		if len(self.column_titles) > 1:
			menu_item = Gtk.SeparatorMenuItem()
			copy_menu.append(menu_item)
			menu_item = Gtk.MenuItem.new_with_label('All')
			menu_item.connect('activate', self.signal_activate_popup_menu_copy, self.column_titles.values())
			copy_menu.append(menu_item)
		return copy_menu 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:22,代码来源:managers.py

示例7: cb_build_missing_parent_nav_menu

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Menu [as 别名]
def cb_build_missing_parent_nav_menu(self, obj, event,
                                         person_handle, family_handle):
        """Builds the menu for a missing parent."""
        self.menu = Gtk.Menu()
        self.menu.set_reserve_toggle_size(False)

        add_item = Gtk.MenuItem.new_with_mnemonic(_('_Add'))
        add_item.connect("activate", self.cb_add_parents, person_handle,
                         family_handle)
        add_item.show()
        self.menu.append(add_item)

        # Add a separator line
        add_item = Gtk.SeparatorMenuItem()
        add_item.show()
        self.menu.append(add_item)

        # Add history-based navigation
        self.add_nav_portion_to_menu(self.menu)
        self.add_settings_to_menu(self.menu)
        self.menu.popup(None, None, None, None, 0, event.time)
        return 1 
开发者ID:gramps-project,项目名称:addons-source,代码行数:24,代码来源:HtreePedigreeView.py

示例8: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Menu [as 别名]
def __init__(self, graph_widget, kind=None, handle=None):
        """
        graph_widget: GraphWidget
        kind: 'person', 'family', 'background'
        handle: person or family handle
        """
        Gtk.Menu.__init__(self)
        self.set_reserve_toggle_size(False)

        self.graph_widget = graph_widget
        self.view = graph_widget.view
        self.dbstate = graph_widget.dbstate

        self.actions = graph_widget.actions

        if kind == 'background':
            self.background_menu()
        elif kind == 'person' and handle is not None:
            self.person_menu(handle)
        elif kind == 'family' and handle is not None:
            self.family_menu(handle) 
开发者ID:gramps-project,项目名称:addons-source,代码行数:23,代码来源:graphview.py

示例9: show_context_menu

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Menu [as 别名]
def show_context_menu(self):
        """
        Show popup menu using different functions according to Gtk version.
        'Gtk.Menu.popup' is deprecated since version 3.22, see:
        https://lazka.github.io/pgi-docs/index.html#Gtk-3.0/classes/Menu.html#Gtk.Menu.popup
        """
        self.prepare_context_menu()
        self.context_menu.show_all()
        if (Gtk.MAJOR_VERSION >= 3) and (Gtk.MINOR_VERSION >= 22):
            self.context_menu.popup_at_pointer(None)
        else:
            self.context_menu.popup(None, None, None, None, 0, 0)

    # ======================================================
    # selection event handlers
    # ====================================================== 
开发者ID:gramps-project,项目名称:addons-source,代码行数:18,代码来源:PhotoTaggingGramplet.py

示例10: family_button_press_cb

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Menu [as 别名]
def family_button_press_cb(self, obj, event, family_handle):
        """
        Call edit family function for mouse left button double click on family
        or submenu for family for mouse right click.
        And setup plug for button press on person widget.
        """
        if event.button == 3 and event.type == Gdk.EventType.BUTTON_PRESS:
            # self.build_full_nav_menu_cb(obj, event, person_handle, family_handle)
            print ("Menu request")
        elif event.button == 1 and event.type == Gdk.EventType._2BUTTON_PRESS:
            family = self.dbstate.db.get_family_from_handle(family_handle)
            if family:
                try:
                    EditFamily(self.dbstate, self.uistate, [], family)
                except WindowActiveError:
                    pass

        return True 
开发者ID:gramps-project,项目名称:addons-source,代码行数:20,代码来源:TimelinePedigreeView.py

示例11: on_mouse_right_click

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Menu [as 别名]
def on_mouse_right_click(self, event, state_machine_m, result):

        menu = Gtk.Menu()
        for sm_id, sm_m in self.model.state_machines.items():
            menu_item = create_menu_item(sm_m.root_state.state.name, constants.BUTTON_EXCHANGE,
                                         callback=self.change_selected_state_machine_id, callback_args=[sm_id])
            menu.append(menu_item)

        menu_item = create_menu_item("New State Machine", constants.BUTTON_ADD,
                                     callback=new_state_machine)
        menu.append(menu_item)

        if self.model.state_machines:
            menu_item = create_menu_item("Close State Machine", constants.BUTTON_CLOSE,
                                         callback=self.on_close_clicked,
                                         callback_args=[state_machine_m, None])
            menu.append(menu_item)

        menu.show_all()
        menu.popup(None, None, None, None, event.get_button()[1], event.time)
        return True 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:23,代码来源:state_machines_editor.py

示例12: createLocalMenu

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Menu [as 别名]
def createLocalMenu(self, items):
        ITEM_MAP = {
            ACCEPT: (_("Accept"), self.on_accept),
            ASSESS: (_("Assess"), self.on_assess),
            OBSERVE: (_("Observe"), self.on_observe),
            FOLLOW: (_("Follow"), self.on_follow),
            CHAT: (_("Chat"), self.on_chat),
            CHALLENGE: (_("Challenge"), self.on_challenge),
            FINGER: (_("Finger"), self.on_finger),
            ARCHIVED: (_("Archived"), self.on_archived), }

        self.menu = Gtk.Menu()
        for item in items:
            if item == SEPARATOR:
                menu_item = Gtk.SeparatorMenuItem()
            else:
                label, callback = ITEM_MAP[item]
                menu_item = Gtk.MenuItem(label)
                menu_item.connect("activate", callback)
            self.menu.append(menu_item)
        self.menu.attach_to_widget(self.tv, None) 
开发者ID:pychess,项目名称:pychess,代码行数:23,代码来源:ParrentListSection.py

示例13: __create_menu

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Menu [as 别名]
def __create_menu(self):
        menu = Gtk.Menu()

        item_settings = Gtk.MenuItem('Settings')
        item_settings.connect("activate", self.__settings_window)
        menu.append(item_settings)

        item_about = Gtk.MenuItem('About')
        item_about.connect("activate", self.__about_window)
        menu.append(item_about)

        item_quit = Gtk.MenuItem('Quit')
        item_quit.connect("activate", self.__quit)
        menu.append(item_quit)
        menu.show_all()

        return menu 
开发者ID:maateen,项目名称:battery-monitor,代码行数:19,代码来源:AppIndicator.py

示例14: get_menu

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Menu [as 别名]
def get_menu(self, callback, menu=None):
        if common.USING_QT:
            for macro in self.macros:
                menu.addAction(MacroAction(menu, macro, callback))
        
        else:
            menu = Gtk.Menu()

            for macro in self.macros:
                menuItem = Gtk.MenuItem(macro.TITLE)
                menuItem.connect("activate", callback, macro)
                menu.append(menuItem)

            menu.show_all()

        return menu 
开发者ID:autokey,项目名称:autokey,代码行数:18,代码来源:macro.py

示例15: build_menu

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Menu [as 别名]
def build_menu(self):
        menu = Gtk.Menu()

        item_unlock = Gtk.MenuItem('Unlock')
        item_unlock.connect('activate', self.unlock)
        menu.append(item_unlock)
        self.item_unlock = item_unlock
        self.item_unlock.set_sensitive(False)  # default state

        item_help = Gtk.MenuItem('Help')
        item_help.connect('activate', self.open_help)
        menu.append(item_help)

        separator = Gtk.SeparatorMenuItem()
        menu.append(separator)

        item_quit = Gtk.MenuItem('Quit')
        item_quit.connect('activate', self.quit)
        menu.append(item_quit)

        menu.show_all()
        return menu 
开发者ID:pykong,项目名称:YubiGuard,代码行数:24,代码来源:YubiGuard.py


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