本文整理汇总了Python中sugar3.graphics.menuitem.MenuItem.show方法的典型用法代码示例。如果您正苦于以下问题:Python MenuItem.show方法的具体用法?Python MenuItem.show怎么用?Python MenuItem.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.menuitem.MenuItem
的用法示例。
在下文中一共展示了MenuItem.show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import show [as 别名]
def __init__(self, file_name, document_path, title, bundle=False):
RadioToolButton.__init__(self)
self._document_path = document_path
self._title = title
self._jobject = None
self.props.tooltip = _("Instance Source")
settings = Gio.Settings("org.sugarlabs.user")
self._color = settings.get_string("color")
icon = Icon(file=file_name, icon_size=Gtk.IconSize.LARGE_TOOLBAR, xo_color=XoColor(self._color))
self.set_icon_widget(icon)
icon.show()
if bundle:
menu_item = MenuItem(_("Duplicate"))
icon = Icon(icon_name="edit-duplicate", icon_size=Gtk.IconSize.MENU, xo_color=XoColor(self._color))
menu_item.connect("activate", self.__copy_to_home_cb)
else:
menu_item = MenuItem(_("Keep"))
icon = Icon(icon_name="document-save", icon_size=Gtk.IconSize.MENU, xo_color=XoColor(self._color))
menu_item.connect("activate", self.__keep_in_journal_cb)
menu_item.set_image(icon)
self.props.palette.menu.append(menu_item)
menu_item.show()
示例2: __init__
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import show [as 别名]
def __init__(self, invite):
Palette.__init__(self, "")
self._invite = invite
menu_item = MenuItem(_("Join"), icon_name="dialog-ok")
menu_item.connect("activate", self.__join_activate_cb)
self.menu.append(menu_item)
menu_item.show()
menu_item = MenuItem(_("Decline"), icon_name="dialog-cancel")
menu_item.connect("activate", self.__decline_activate_cb)
self.menu.append(menu_item)
menu_item.show()
bundle_id = invite.get_bundle_id()
registry = bundleregistry.get_registry()
self._bundle = registry.get_bundle(bundle_id)
if self._bundle:
name = self._bundle.get_name()
else:
name = bundle_id
self.set_primary_text(GLib.markup_escape_text(name))
示例3: _reload_fonts
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import show [as 别名]
def _reload_fonts(self, monitor, gio_file, other_file, event):
if event != Gio.FileMonitorEvent.CHANGES_DONE_HINT:
return
self._font_white_list = []
self._font_white_list.extend(DEFAULT_FONTS)
fonts_file = open(USER_FONTS_FILE_PATH)
for line in fonts_file:
self._font_white_list.append(line.strip())
# update the menu
for child in self.props.palette.menu.get_children():
self.props.palette.menu.remove(child)
child = None
context = self.get_pango_context()
tmp_list = []
for family in context.list_families():
name = family.get_name()
if name in self._font_white_list:
tmp_list.append(name)
for font_name in sorted(tmp_list):
menu_item = MenuItem(font_name)
markup = '<span font="%s">%s</span>' % (font_name, font_name)
menu_item.get_children()[0].set_markup(markup)
menu_item.connect('activate', self.__menu_activated, font_name)
self.props.palette.menu.append(menu_item)
menu_item.show()
return False
示例4: __init__
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import show [as 别名]
def __init__(self, file_name, document_path, title, bundle=False):
RadioToolButton.__init__(self)
self._document_path = document_path
self._title = title
self._jobject = None
self.props.tooltip = _('Instance Source')
client = GConf.Client.get_default()
self._color = client.get_string('/desktop/sugar/user/color')
icon = Icon(file=file_name,
icon_size=Gtk.IconSize.LARGE_TOOLBAR,
xo_color=XoColor(self._color))
self.set_icon_widget(icon)
icon.show()
if bundle:
menu_item = MenuItem(_('Duplicate'))
icon = Icon(icon_name='edit-duplicate',
icon_size=Gtk.IconSize.MENU,
xo_color=XoColor(self._color))
menu_item.connect('activate', self.__copy_to_home_cb)
else:
menu_item = MenuItem(_('Keep'))
icon = Icon(icon_name='document-save',
icon_size=Gtk.IconSize.MENU,
xo_color=XoColor(self._color))
menu_item.connect('activate', self.__keep_in_journal_cb)
menu_item.set_image(icon)
self.props.palette.menu.append(menu_item)
menu_item.show()
示例5: __init__
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import show [as 别名]
def __init__(self, _parent):
SugarEditToolbar.__init__(self)
self._parent = _parent
self.undo.connect('clicked', self.__undo_cb)
self.redo.connect('clicked', self.__redo_cb)
self.copy.connect('clicked', self.__copy_cb)
self.paste.connect('clicked', self.__paste_cb)
menu_item = MenuItem(_('Cut'))
menu_item.connect('activate', self.__cut_cb)
menu_item.show()
self.copy.get_palette().menu.append(menu_item)
self.insert(Gtk.SeparatorToolItem(), -1)
self.erase_button = ToolButton('edit-delete')
self.erase_button.set_tooltip(_('Erase selected thought(s)'))
self.erase_button.connect('clicked', self.__delete_cb)
self.insert(self.erase_button, -1)
self.show_all()
self.clipboard = Gtk.Clipboard()
self.copy.set_sensitive(False)
self.paste.set_sensitive(False)
self.erase_button.set_sensitive(False)
示例6: create_palette
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import show [as 别名]
def create_palette(self):
primary_text = glib.markup_escape_text(self._model.bundle.get_name())
secondary_text = glib.markup_escape_text(self._model.get_name())
palette_icon = Icon(file=self._model.bundle.get_icon(),
xo_color=self._model.get_color())
palette_icon.props.icon_size = Gtk.IconSize.LARGE_TOOLBAR
palette = Palette(None,
primary_text=primary_text,
secondary_text=secondary_text,
icon=palette_icon)
private = self._model.props.private
joined = get_owner_instance() in self._model.props.buddies
if joined:
item = MenuItem(_('Resume'), 'activity-start')
item.connect('activate', self.__palette_item_clicked_cb)
item.show()
palette.menu.append(item)
elif not private:
item = MenuItem(_('Join'), 'activity-start')
item.connect('activate', self.__palette_item_clicked_cb)
item.show()
palette.menu.append(item)
self.connect_to_palette_pop_events(palette)
return palette
示例7: __init__
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import show [as 别名]
def __init__(self, file_name, document_path, title, bundle=False):
RadioToolButton.__init__(self)
self._document_path = document_path
self._title = title
self._jobject = None
self.props.tooltip = _('Instance Source')
settings = Gio.Settings('org.sugarlabs.user')
self._color = settings.get_string('color')
icon = Icon(file=file_name,
pixel_size=style.STANDARD_ICON_SIZE,
xo_color=XoColor(self._color))
self.set_icon_widget(icon)
icon.show()
if bundle:
menu_item = MenuItem(_('Duplicate'))
icon = Icon(icon_name='edit-duplicate',
pixel_size=style.SMALL_ICON_SIZE,
xo_color=XoColor(self._color))
menu_item.connect('activate', self.__copy_to_home_cb)
else:
menu_item = MenuItem(_('Keep'))
icon = Icon(icon_name='document-save',
pixel_size=style.SMALL_ICON_SIZE,
xo_color=XoColor(self._color))
menu_item.connect('activate', self.__keep_in_journal_cb)
menu_item.set_image(icon)
self.props.palette.menu.append(menu_item)
menu_item.show()
示例8: __init__
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import show [as 别名]
def __init__(self):
Gtk.ComboBox.__init__(self)
ToolButton.__init__(self, icon_name='font-text',
tooltip=_('Select font'))
self.connect('clicked', self.__font_selection_cb)
context = self.get_pango_context()
self._init_font_list()
self._font_name = 'Sans'
font_names = []
for family in context.list_families():
name = family.get_name()
if name in self._font_white_list:
font_names.append(name)
for font_name in sorted(font_names):
menu_item = MenuItem(font_name)
markup = '<span font="%s">%s</span>' % (font_name, font_name)
menu_item.get_children()[0].set_markup(markup)
menu_item.connect('activate', self.__menu_activated, font_name)
self.props.palette.menu.append(menu_item)
menu_item.show()
self.show()
示例9: __init__
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import show [as 别名]
def __init__(self, title, url, owner_document):
Palette.__init__(self)
self._title = title
self._url = url
self._owner_document = owner_document
self.props.primary_text = title
self.props.secondary_text = url
menu_item = MenuItem(_('Keep image'))
icon = Icon(icon_name='document-save', xo_color=profile.get_color(),
icon_size=Gtk.IconSize.MENU)
menu_item.set_image(icon)
menu_item.connect('activate', self.__download_activate_cb)
self.menu.append(menu_item)
menu_item.show()
menu_item = MenuItem(_('Copy image'))
icon = Icon(icon_name='edit-copy', xo_color=profile.get_color(),
icon_size=Gtk.IconSize.MENU)
menu_item.set_image(icon)
menu_item.connect('activate', self.__copy_activate_cb)
self.menu.append(menu_item)
menu_item.show()
示例10: __init__
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import show [as 别名]
def __init__(self, invite):
Palette.__init__(self, '')
self._invite = invite
menu_item = MenuItem(_('Join'), icon_name='dialog-ok')
menu_item.connect('activate', self.__join_activate_cb)
self.menu.append(menu_item)
menu_item.show()
menu_item = MenuItem(_('Decline'), icon_name='dialog-cancel')
menu_item.connect('activate', self.__decline_activate_cb)
self.menu.append(menu_item)
menu_item.show()
bundle_id = invite.get_bundle_id()
registry = bundleregistry.get_registry()
self._bundle = registry.get_bundle(bundle_id)
if self._bundle:
name = self._bundle.get_name()
else:
name = bundle_id
self.set_primary_text(name)
示例11: __init__
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import show [as 别名]
def __init__(self, calc):
Gtk.Toolbar.__init__(self)
copy_tool = ToolButton('edit-copy')
copy_tool.set_tooltip(_('Copy'))
copy_tool.set_accelerator(_('<ctrl>c'))
copy_tool.connect('clicked', lambda x: calc.text_copy())
self.insert(copy_tool, -1)
menu_item = MenuItem(_('Cut'))
try:
menu_item.set_accelerator(_('<ctrl>x'))
except AttributeError:
pass
menu_item.connect('activate', lambda x: calc.text_cut())
menu_item.show()
copy_tool.get_palette().menu.append(menu_item)
self.insert(IconToolButton('edit-paste', _('Paste'),
lambda x: calc.text_paste(),
alt_html='Paste'), -1)
self.show_all()
示例12: _add_erase_option
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import show [as 别名]
def _add_erase_option(self, registry, activity_info):
menu_item = MenuItem(_('Erase'), 'list-remove')
menu_item.connect('activate', self.__erase_activate_cb)
self.menu.append(menu_item)
menu_item.show()
if not os.access(activity_info.get_path(), os.W_OK) or \
registry.is_activity_protected(self._bundle_id):
menu_item.props.sensitive = False
示例13: _setup_octaves_palette
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import show [as 别名]
def _setup_octaves_palette(self):
self._octaves_palette = self._octaves_button.get_palette()
for octave in range(9):
menu_item = MenuItem(icon_name='',
text_label=str(octave))
menu_item.connect('activate', self._octave_selected_cb, octave)
self._octaves_palette.menu.append(menu_item)
menu_item.show()
示例14: _setup_notes_palette
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import show [as 别名]
def _setup_notes_palette(self):
self._notes_palette = self._notes_button.get_palette()
for note in NOTES:
menu_item = MenuItem(icon_name='',
text_label=note)
menu_item.connect('activate', self._note_selected_cb, note)
self._notes_palette.menu.append(menu_item)
menu_item.show()
示例15: create_palette
# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import show [as 别名]
def create_palette(self, text, help_cb):
p = Palette(text)
if help_cb is not None:
item = MenuItem(_('Help'), 'action-help')
item.connect('activate', help_cb)
item.show()
p.menu.append(item)
self.set_palette(p)