本文整理汇总了Python中gi.repository.Gtk.SeparatorMenuItem方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.SeparatorMenuItem方法的具体用法?Python Gtk.SeparatorMenuItem怎么用?Python Gtk.SeparatorMenuItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.SeparatorMenuItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_menu_item
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorMenuItem [as 别名]
def add_menu_item(self, menu_path, handler=None):
"""
Add a new item into the main menu bar of the application. Menu items
created through this method are automatically removed when the plugin
is disabled. If no *handler* is specified, the menu item will be a
separator, otherwise *handler* will automatically be connected to the
menu item's ``activate`` signal.
:param str menu_path: The path to the menu item, delimited with > characters.
:param handler: The optional callback function to be connected to the new :py:class:`Gtk.MenuItem` instance's activate signal.
:return: The newly created and added menu item.
:rtype: :py:class:`Gtk.MenuItem`
"""
menu_path = _split_menu_path(menu_path)
if handler is None:
menu_item = Gtk.SeparatorMenuItem()
else:
menu_item = Gtk.MenuItem.new_with_label(menu_path.pop())
self.signal_connect('activate', handler, gobject=menu_item)
return self._insert_menu_item(menu_path, menu_item)
示例2: get_popup_copy_submenu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorMenuItem [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
示例3: cb_build_missing_parent_nav_menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorMenuItem [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
示例4: set_perspective_menuitems
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorMenuItem [as 别名]
def set_perspective_menuitems(self, name, menuitems, default=True):
perspective, button, index = self.perspectives[name]
for item in perspective.menuitems:
if item in self.viewmenu:
self.viewmenu.remove(item)
perspective.menuitems = []
item = Gtk.SeparatorMenuItem()
perspective.menuitems.append(item)
self.viewmenu.append(item)
item.show()
for item in menuitems:
perspective.menuitems.append(item)
self.viewmenu.append(item)
if default:
item.set_active(True)
item.show()
示例5: createLocalMenu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorMenuItem [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)
示例6: insert_separator
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorMenuItem [as 别名]
def insert_separator(self, menubar, at_position):
"""
add a separator to the popup (only required for RB2.98 and earlier)
:param menubar: `str` is the name GtkMenu (or ignored for RB2.99+)
:param position: `int` position to add to GtkMenu (ignored for RB2.99+)
"""
if not is_rb3(self.shell):
menu_item = Gtk.SeparatorMenuItem().new()
menu_item.set_visible(True)
self._rbmenu_items['separator' + str(self._unique_num)] = menu_item
self._unique_num = self._unique_num + 1
bar = self.get_menu_object(menubar)
bar.insert(menu_item, at_position)
bar.show_all()
uim = self.shell.props.ui_manager
uim.ensure_update()
示例7: add2menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorMenuItem [as 别名]
def add2menu(menu, text=None, icon=None, conector_event=None,
conector_action=None):
if text is not None:
menu_item = Gtk.ImageMenuItem.new_with_label(text)
if icon:
image = Gtk.Image.new_from_file(icon)
menu_item.set_image(image)
menu_item.set_always_show_image(True)
else:
if icon is None:
menu_item = Gtk.SeparatorMenuItem()
else:
menu_item = Gtk.ImageMenuItem.new_from_file(icon)
menu_item.set_always_show_image(True)
if conector_event is not None and conector_action is not None:
menu_item.connect(conector_event, conector_action)
menu_item.show()
menu.append(menu_item)
return menu_item
示例8: create_gtk_builder
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorMenuItem [as 别名]
def create_gtk_builder(glade_file):
"""
Create a Gtk builder and load the glade file.
"""
builder = Gtk.Builder()
builder.set_translation_domain('safeeyes')
builder.add_from_file(glade_file)
# Tranlslate all sub components
for obj in builder.get_objects():
if (not isinstance(obj, Gtk.SeparatorMenuItem)) and hasattr(obj, "get_label"):
label = obj.get_label()
if label is not None:
obj.set_label(_(label))
elif hasattr(obj, "get_title"):
title = obj.get_title()
if title is not None:
obj.set_title(_(title))
return builder
示例9: build_menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorMenuItem [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
示例10: populate_popup_add_separator
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorMenuItem [as 别名]
def populate_popup_add_separator(menu, prepend=False):
'''Convenience function that adds a C{Gtk.SeparatorMenuItem}
to a context menu. Checks if the menu already contains items,
if it is empty does nothing. Also if the menu already has a
seperator in the required place this function does nothing.
This helps with building menus more dynamically.
@param menu: the C{Gtk.Menu} object for the popup
@param prepend: if C{False} append, if C{True} prepend
'''
items = menu.get_children()
if not items:
pass # Nothing to do
elif prepend:
if not isinstance(items[0], Gtk.SeparatorMenuItem):
sep = Gtk.SeparatorMenuItem()
menu.prepend(sep)
else:
if not isinstance(items[-1], Gtk.SeparatorMenuItem):
sep = Gtk.SeparatorMenuItem()
menu.append(sep)
示例11: do_initialize_popup
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorMenuItem [as 别名]
def do_initialize_popup(self, menu):
model, treeiter = self.get_selection().get_selected()
if treeiter is None:
popup_name, path = PAGE_ROOT_ACTIONS, None
else:
mytreeiter = model.get_user_data(treeiter)
if mytreeiter.hint == IS_PAGE:
popup_name = PAGE_EDIT_ACTIONS
path = self.get_selected_path()
else:
popup_name, path = None, None
if popup_name:
uiactions = UIActions(
self,
self.notebook,
path,
self.navigation,
)
uiactions.populate_menu_with_actions(popup_name, menu)
sep = Gtk.SeparatorMenuItem()
menu.append(sep)
self.populate_popup_expand_collapse(menu)
menu.show_all()
示例12: get_trayicon_menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorMenuItem [as 别名]
def get_trayicon_menu(self):
'''Returns the main 'tray icon menu'''
menu = Gtk.Menu()
item = Gtk.MenuItem.new_with_mnemonic(_('_Quick Note...')) # T: menu item in tray icon menu
item.connect_object('activate', self.__class__.do_quick_note, self)
menu.append(item)
menu.append(Gtk.SeparatorMenuItem())
notebooks = self.list_all_notebooks()
self.populate_menu_with_notebooks(menu, notebooks)
item = Gtk.MenuItem.new_with_mnemonic(' ' + _('_Other...')) # Hack - using ' ' to indent visually
# T: menu item in tray icon menu
item.connect_object('activate', self.__class__.do_open_notebook, self)
menu.append(item)
menu.append(Gtk.SeparatorMenuItem())
item = Gtk.MenuItem.new_with_mnemonic(_('_Quit')) # T: menu item in tray icon menu
item.connect_object('activate', self.__class__.do_quit, self)
menu.append(item)
return menu
示例13: on_populate_popup
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorMenuItem [as 别名]
def on_populate_popup(self, o, menu):
sep = Gtk.SeparatorMenuItem()
menu.append(sep)
item = Gtk.CheckMenuItem(_('Show Tasks as Flat List'))
# T: Checkbox in task list - hides parent items
item.set_active(self.uistate['show_flatlist'])
item.connect('toggled', self.on_show_flatlist_toggle)
item.show_all()
menu.append(item)
item = Gtk.CheckMenuItem(_('Only Show Active Tasks'))
# T: Checkbox in task list - this options hides tasks that are not yet started
item.set_active(self.uistate['only_show_act'])
item.connect('toggled', self.on_show_active_toggle)
item.show_all()
menu.append(item)
示例14: signal_textview_populate_popup
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorMenuItem [as 别名]
def signal_textview_populate_popup(self, textview, menu):
# create and populate the 'Insert' submenu
menu = managers.MenuManager(menu)
insert_submenu = menu.append_submenu('Insert')
insert_submenu.append('Inline Image', self.signal_activate_popup_menu_insert_image)
insert_submenu.append('Tracking Image Tag', self.signal_activate_popup_menu_insert, activate_args=('{{ tracking_dot_image_tag }}',))
insert_submenu.append('Webserver URL', self.signal_activate_popup_menu_insert, activate_args=('{{ url.webserver }}',))
# create and populate the 'Date & Time' submenu
insert_datetime_submenu = insert_submenu.append_submenu('Date & Time')
formats = [
'%a %B %d, %Y',
'%b %d, %y',
'%m/%d/%y',
None,
'%I:%M %p',
'%H:%M:%S'
]
dt_now = datetime.datetime.now()
for fmt in formats:
if fmt:
insert_datetime_submenu.append(
dt_now.strftime(fmt),
self.signal_activate_popup_menu_insert,
activate_args=("{{{{ time.local | strftime('{0}') }}}}".format(fmt),)
)
else:
insert_datetime_submenu.append_item(Gtk.SeparatorMenuItem())
return True
示例15: get_popup_menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorMenuItem [as 别名]
def get_popup_menu(self, handle_button_press=True):
"""
Create a :py:class:`Gtk.Menu` with entries for copying and optionally
delete cell data from within the treeview. The delete option will only
be available if a delete callback was previously set.
:param bool handle_button_press: Whether or not to connect a handler for displaying the popup menu.
:return: The populated popup menu.
:rtype: :py:class:`Gtk.Menu`
"""
popup_copy_submenu = self.get_popup_copy_submenu()
popup_menu = Gtk.Menu.new()
menu_item = Gtk.MenuItem.new_with_label('Copy')
menu_item.set_submenu(popup_copy_submenu)
popup_menu.append(menu_item)
self._menu_items['Copy'] = menu_item
if self.cb_delete:
menu_item = Gtk.SeparatorMenuItem()
popup_menu.append(menu_item)
menu_item = Gtk.MenuItem.new_with_label('Delete')
menu_item.connect('activate', self.signal_activate_popup_menu_delete)
popup_menu.append(menu_item)
self._menu_items['Delete'] = menu_item
popup_menu.show_all()
if handle_button_press:
self.treeview.connect('button-press-event', self.signal_button_pressed, popup_menu)
return popup_menu