本文整理汇总了Python中sugar3.graphics.menuitem.MenuItem类的典型用法代码示例。如果您正苦于以下问题:Python MenuItem类的具体用法?Python MenuItem怎么用?Python MenuItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
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()
示例2: __init__
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()
示例3: create_palette
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
示例4: __init__
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))
示例5: __init__
def __init__(self, cb_object):
Palette.__init__(self, text_maxlen=100)
self._cb_object = cb_object
self.set_group_id('frame')
cb_service = clipboard.get_instance()
cb_service.connect('object-state-changed',
self._object_state_changed_cb)
self._remove_item = MenuItem(pgettext('Clipboard', 'Remove'),
'list-remove')
self._remove_item.connect('activate', self._remove_item_activate_cb)
self.menu.append(self._remove_item)
self._remove_item.show()
self._open_item = MenuItem(_('Open'), 'zoom-activity')
self._open_item.connect('activate', self._open_item_activate_cb)
self.menu.append(self._open_item)
self._open_item.show()
self._journal_item = MenuItem(_('Keep'))
color = profile.get_color()
icon = Icon(icon_name='document-save',
pixel_size=style.SMALL_ICON_SIZE,
xo_color=color)
self._journal_item.set_image(icon)
self._journal_item.connect('activate', self._journal_item_activate_cb)
self.menu.append(self._journal_item)
self._journal_item.show()
self._update()
示例6: __init__
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)
示例7: __init__
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)
示例8: refresh_activity_list
def refresh_activity_list(self):
self.menu = Gtk.Menu()
def process_dir(activity_path):
for dir_name in sorted(os.listdir(activity_path)):
bundles_installed = []
if dir_name.endswith('.activity'):
bundle_dir = os.path.join(activity_path, dir_name)
bundle = ActivityBundle(bundle_dir)
bundles_installed.append(bundle)
item = MenuItem(file_name=bundle.get_icon(),
xo_color=xocolor.XoColor())
item.set_label(bundle.get_name())
item.set_reserve_indicator(True)
item.set_submenu(self.make_submenu(bundle))
self.menu.append(item)
process_dir('/usr/share/sugar/activities/')
process_dir(activities_path) # ~/Activities
separator = Gtk.SeparatorMenuItem()
self.menu.append(separator)
about = MenuItem()
about.set_label("About")
about.connect("activate", self.show_about_dialog)
self.menu.append(about)
quit = MenuItem()
quit.set_label("Quit")
quit.connect("activate", Gtk.main_quit)
self.menu.append(quit)
self.menu.show_all()
示例9: __init__
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()
示例10: __init__
def __init__(self, cb_object):
Palette.__init__(self, text_maxlen=100)
self._cb_object = cb_object
self.set_group_id('frame')
cb_service = clipboard.get_instance()
cb_service.connect('object-state-changed',
self._object_state_changed_cb)
self._remove_item = MenuItem(pgettext('Clipboard', 'Remove'),
'list-remove')
self._remove_item.connect('activate', self._remove_item_activate_cb)
self.menu.append(self._remove_item)
self._remove_item.show()
self._open_item = MenuItem(_('Open'), 'zoom-activity')
self._open_item.connect('activate', self._open_item_activate_cb)
self.menu.append(self._open_item)
self._open_item.show()
self._journal_item = MenuItem(_('Keep'))
client = GConf.Client.get_default()
color = XoColor(client.get_string('/desktop/sugar/user/color'))
icon = Icon(icon_name='document-save', icon_size=Gtk.IconSize.MENU,
xo_color=color)
self._journal_item.set_image(icon)
self._journal_item.connect('activate', self._journal_item_activate_cb)
self.menu.append(self._journal_item)
self._journal_item.show()
self._update()
示例11: _setup_notes_palette
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()
示例12: __init__
def __init__(self, account, get_uid_list, is_active):
MenuItem.__init__(self, ACCOUNT_NAME)
self._account = account
self.set_image(Icon(icon_name=ACCOUNT_ICON,
icon_size=Gtk.IconSize.MENU))
self.show()
self._get_uid_list = get_uid_list
self.connect('activate', self.__share_menu_cb)
示例13: __init__
def __init__(self, account, get_uid_list, is_active):
MenuItem.__init__(self, ACCOUNT_DESCRIPTION)
self._account = account
self.set_image(Icon(icon_name=ACCOUNT_ICON,
icon_size=Gtk.IconSize.MENU))
self.show()
self._get_uid_list = get_uid_list
self.connect('activate', self.upload_file)
示例14: _setup_octaves_palette
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()
示例15: _add_erase_option
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