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


Python menuitem.MenuItem类代码示例

本文整理汇总了Python中sugar.graphics.menuitem.MenuItem的典型用法代码示例。如果您正苦于以下问题:Python MenuItem类的具体用法?Python MenuItem怎么用?Python MenuItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: _reload_session_history

    def _reload_session_history(self, current_page_index=None):
        session_history = self._browser.web_navigation.sessionHistory
        if current_page_index is None:
            current_page_index = session_history.index

        for palette in (self._back.get_palette(), self._forward.get_palette()):
            for menu_item in palette.menu.get_children():
                palette.menu.remove(menu_item)

        if current_page_index > _MAX_HISTORY_ENTRIES:
            bottom = current_page_index - _MAX_HISTORY_ENTRIES
        else:
            bottom = 0
        if  (session_history.count - current_page_index) > \
               _MAX_HISTORY_ENTRIES:
            top = current_page_index + _MAX_HISTORY_ENTRIES + 1
        else:
            top = session_history.count

        for i in range(bottom, top):
            if i == current_page_index:
                continue

            entry = session_history.getEntryAtIndex(i, False)
            menu_item = MenuItem(entry.title, text_maxlen=60)
            menu_item.connect('activate', self._history_item_activated_cb, i)

            if i < current_page_index:
                palette = self._back.get_palette()
                palette.menu.prepend(menu_item)
            elif i > current_page_index:
                palette = self._forward.get_palette()
                palette.menu.append(menu_item)

            menu_item.show()
开发者ID:lucian1900,项目名称:Webified,代码行数:35,代码来源:webtoolbar.py

示例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')

        client = gconf.client_get_default()
        self._color = client.get_string('/desktop/sugar/user/color')
        icon = Icon(file=file_name,
                    icon_size=gtk.ICON_SIZE_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.ICON_SIZE_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.ICON_SIZE_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()
开发者ID:nemesiscodex,项目名称:JukyOS-sugar,代码行数:34,代码来源:viewsource.py

示例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())
        p_icon = Icon(file=self._model.bundle.get_icon(),
                      xo_color=self._model.get_color())
        p_icon.props.icon_size = gtk.ICON_SIZE_LARGE_TOOLBAR
        p = palette.Palette(None,
                            primary_text=primary_text,
                            secondary_text=secondary_text,
                            icon=p_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._clicked_cb)
            item.show()
            p.menu.append(item)
        elif not private:
            item = MenuItem(_('Join'), 'activity-start')
            item.connect('activate', self._clicked_cb)
            item.show()
            p.menu.append(item)

        return p
开发者ID:nemesiscodex,项目名称:JukyOS-sugar,代码行数:26,代码来源:meshbox.py

示例4: __init__

    def __init__(self, _parent):
        activity.EditToolbar.__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.child.set_sensitive(False)
        self.paste.child.set_sensitive(False)
        self.erase_button.set_sensitive(False)
开发者ID:Daksh,项目名称:Labyrinth,代码行数:28,代码来源:labyrinthactivity.py

示例5: __init__

    def __init__(self, activity_info, journal_entries):
        ActivityPalette.__init__(self, activity_info)

        if not journal_entries:
            xo_color = XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(),
                                          style.COLOR_TRANSPARENT.get_svg()))
        else:
            xo_color = misc.get_icon_color(journal_entries[0])

        self.props.icon = Icon(file=activity_info.get_icon(),
                               xo_color=xo_color,
                               icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)

        if journal_entries:
            self.props.secondary_text = journal_entries[0]['title']

            menu_items = []
            for entry in journal_entries:
                icon_file_name = misc.get_icon_name(entry)
                color = misc.get_icon_color(entry)

                menu_item = MenuItem(text_label=entry['title'],
                                     file_name=icon_file_name,
                                     xo_color=color)
                menu_item.connect('activate', self.__resume_entry_cb, entry)
                menu_items.append(menu_item)
                menu_item.show()

            if journal_entries:
                separator = gtk.SeparatorMenuItem()
                menu_items.append(separator)
                separator.show()

            for i in range(0, len(menu_items)):
                self.menu.insert(menu_items[i], i)
开发者ID:davidmason,项目名称:glycogen,代码行数:35,代码来源:activitybox.py

示例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(glib.markup_escape_text(name))
开发者ID:nemesiscodex,项目名称:JukyOS-sugar,代码行数:25,代码来源:activitiestray.py

示例7: __init__

    def __init__(self):
        gtk.Toolbar.__init__(self)
        self.back = ToolButton('go-previous')
        self.back.set_tooltip(_('Back'))
        self.back.props.sensitive = False
        palette = self.back.get_palette()
        self.prev_page = MenuItem(text_label= _("Previous page"))
        palette.menu.append(self.prev_page) 
        self.prev_page.show_all()        
        self.back.connect('clicked', self.go_back_cb)
        self.prev_page.connect('activate', self.go_back_cb)
        self.insert(self.back, -1)
        self.back.show()

        self.forward = ToolButton('go-next')
        self.forward.set_tooltip(_('Forward'))
        self.forward.props.sensitive = False
        palette = self.forward.get_palette()
        self.next_page = MenuItem(text_label= _("Next page"))
        palette.menu.append(self.next_page) 
        self.next_page.show_all()        
        self.forward.connect('clicked', self.go_forward_cb)
        self.next_page.connect('activate', self.go_forward_cb)
        self.insert(self.forward, -1)
        self.forward.show()

        num_page_item = gtk.ToolItem()

        self._num_page_entry = gtk.Entry()
        self._num_page_entry.set_text('0')
        self._num_page_entry.set_alignment(1)
        self._num_page_entry.connect('insert-text',
                                     self._num_page_entry_insert_text_cb)
        self._num_page_entry.connect('activate',
                                     self._num_page_entry_activate_cb)

        self._num_page_entry.set_width_chars(4)

        num_page_item.add(self._num_page_entry)
        self._num_page_entry.show()

        self.insert(num_page_item, -1)
        num_page_item.show()

        total_page_item = gtk.ToolItem()

        self._total_page_label = gtk.Label()

        label_attributes = pango.AttrList()
        label_attributes.insert(pango.AttrSize(14000, 0, -1))
        label_attributes.insert(pango.AttrForeground(65535, 65535, 65535, 0, -1))
        self._total_page_label.set_attributes(label_attributes)

        self._total_page_label.set_text(' / 0')
        total_page_item.add(self._total_page_label)
        self._total_page_label.show()

        self.insert(total_page_item, -1)
        total_page_item.show()
开发者ID:leonardcj,项目名称:read-sd-comics,代码行数:59,代码来源:readtoolbar.py

示例8: _setup_quality_palette

 def _setup_quality_palette(self):
     self._quality_palette = self._quality_button.get_palette()
     for quality in QUALITY_VALUES:
         text = _("%s quality") % (quality)
         menu_item = MenuItem(icon_name=quality + "-quality", text_label=text)
         menu_item.connect("activate", self._quality_selected_cb, quality)
         self._quality_palette.menu.append(menu_item)
         menu_item.show()
开发者ID:quozl,项目名称:record-activity,代码行数:8,代码来源:record.py

示例9: _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()
开发者ID:leonardcj,项目名称:Measure,代码行数:9,代码来源:tuning_toolbar.py

示例10: _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()
开发者ID:leonardcj,项目名称:Measure,代码行数:9,代码来源:tuning_toolbar.py

示例11: _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
开发者ID:nemesiscodex,项目名称:JukyOS-sugar,代码行数:9,代码来源:activitieslist.py

示例12: _setup_log_palette

    def _setup_log_palette(self):
        self._log_palette = self._log_button.get_palette()

        for tenth_seconds in LOG_TIMER_VALUES:
            text = self._log_to_string(tenth_seconds)
            menu_item = MenuItem(icon_name="timer-%d" % (tenth_seconds), text_label=self._log_to_string(tenth_seconds))
            menu_item.connect("activate", self._log_selected_cb, tenth_seconds)
            self._log_palette.menu.append(menu_item)
            menu_item.show()
开发者ID:quozl,项目名称:Measure,代码行数:9,代码来源:sensor_toolbar.py

示例13: __init__

    def __init__(self, url):
        Palette.__init__(self, url)

        self.owns_clipboard = False
        self.url = _url_check_protocol(url)

        menu_item = MenuItem(_('Copy to Clipboard'), 'edit-copy')
        menu_item.connect('activate', self._copy_to_clipboard_cb)
        self.menu.append(menu_item)
        menu_item.show()
开发者ID:Gopaal,项目名称:2014-interns,代码行数:10,代码来源:box.py

示例14: __init__

    def __init__(self, activity, abi):
        ToolButton.__init__(self, "document-save")
        self.props.tooltip = _("Export")
        self.props.label = _("Export")

        for i in self._EXPORT_FORMATS:
            menu_item = MenuItem(i["title"])
            menu_item.connect("activate", self.__activate_cb, activity, abi, i)
            self.props.palette.menu.append(menu_item)
            menu_item.show()
开发者ID:Daksh,项目名称:devtutor,代码行数:10,代码来源:widgets.py

示例15: _setup_instrument_palette

    def _setup_instrument_palette(self):
        self.instrument_palette = self._instrument_button.get_palette()

        self.instrument = []
        for k in INSTRUMENT_DICT.keys():
            self.instrument.append(k)
            menu_item = MenuItem(icon_name='',
                                 text_label=k)
            menu_item.connect('activate', self.instrument_selected_cb, k)
            self.instrument_palette.menu.append(menu_item)
            menu_item.show()
开发者ID:leonardcj,项目名称:Measure,代码行数:11,代码来源:tuning_toolbar.py


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