• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python palettemenu.PaletteMenuItem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _create_palette

    def _create_palette(self):
        self._palette_icon = Icon(
            icon_name=self._ICON_NAME + str(self._channel),
            pixel_size=style.STANDARD_ICON_SIZE)

        palette_ = palette.Palette(_('Ad-hoc Network %d') % (self._channel, ),
                                   icon=self._palette_icon)

        self.menu_box = Gtk.VBox()

        self._connect_item = PaletteMenuItem(_('Connect'))
        icon = Icon(pixel_size=style.SMALL_ICON_SIZE, icon_name='dialog-ok')
        self._connect_item.set_image(icon)
        self._connect_item.connect('activate', self.__connect_activate_cb)
        self.menu_box.add(self._connect_item)

        self._disconnect_item = PaletteMenuItem(_('Disconnect'))
        icon = Icon(pixel_size=style.SMALL_ICON_SIZE, icon_name='media-eject')
        self._disconnect_item.set_image(icon)
        self._disconnect_item.connect(
            'activate', self.__disconnect_activate_cb)
        self.menu_box.add(self._disconnect_item)

        palette_.set_content(self.menu_box)
        self.menu_box.show_all()
        self._disconnect_item.hide()

        self.connect_to_palette_pop_events(palette_)

        return palette_
开发者ID:AbrahmAB,项目名称:sugar,代码行数:30,代码来源:networkviews.py


示例2: 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

        menu_box = PaletteMenuBox()

        if joined:
            item = PaletteMenuItem(_('Resume'))
            icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='activity-start')
            item.set_image(icon)
            item.connect('activate', self.__palette_item_clicked_cb)
            menu_box.append_item(item)
        elif not private:
            item = PaletteMenuItem(_('Join'))
            icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='activity-start')
            item.set_image(icon)
            item.connect('activate', self.__palette_item_clicked_cb)
            menu_box.append_item(item)

        palette.set_content(menu_box)
        menu_box.show_all()

        self.connect_to_palette_pop_events(palette)
        return palette
开发者ID:ajaygarg84,项目名称:sugar,代码行数:34,代码来源:meshbox.py


示例3: setup_rollover_options

    def setup_rollover_options(self, info):
        palette = Palette(info, text_maxlen=50)
        self.set_palette(palette)

        box = PaletteMenuBox()
        palette.set_content(box)
        box.show()

        menu_item = PaletteMenuItem(_('Remove'), 'list-remove')
        menu_item.connect('activate', self.item_remove_cb)
        box.append_item(menu_item)
        menu_item.show()

        separator = PaletteMenuItemSeparator()
        box.append_item(separator)
        separator.show()

        textview = Gtk.TextView()
        textview.props.height_request = style.GRID_CELL_SIZE * 2
        textview.props.width_request = style.GRID_CELL_SIZE * 3
        textview.props.hexpand = True
        textview.props.vexpand = True
        box.append_item(textview)
        textview.show()

        buffer = textview.get_buffer()
        if self.notes is None:
            buffer.set_text(_('Take notes on this page'))
        else:
            buffer.set_text(self.notes)
        buffer.connect('changed', self.__buffer_changed_cb)
开发者ID:sugarlabs,项目名称:browse-activity,代码行数:31,代码来源:linkbutton.py


示例4: __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_WHITE.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,
                               pixel_size=style.STANDARD_ICON_SIZE)

        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 = PaletteMenuItem(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 = PaletteMenuItemSeparator()
                menu_items.append(separator)
                separator.show()

            for i in range(0, len(menu_items)):
                self.menu_box.pack_start(menu_items[i], True, True, 0)
开发者ID:AxEofBone7,项目名称:sugar,代码行数:35,代码来源:favoritesview.py


示例5: _create_palette

    def _create_palette(self):
        icon_name = get_icon_state(_AP_ICON_NAME, self._strength)
        self._palette_icon = Icon(icon_name=icon_name,
                                  icon_size=style.STANDARD_ICON_SIZE,
                                  badge_name=self.props.badge_name)

        label = GLib.markup_escape_text(self._display_name)
        p = palette.Palette(primary_text=label, icon=self._palette_icon)

        self.menu_box = Gtk.VBox()

        self._connect_item = PaletteMenuItem(_('Connect'))
        icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='dialog-ok')
        self._connect_item.set_image(icon)
        self._connect_item.connect('activate', self.__connect_activate_cb)
        self.menu_box.add(self._connect_item)

        self._disconnect_item = PaletteMenuItem(_('Disconnect'))
        icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='media-eject')
        self._disconnect_item.set_image(icon)
        self._disconnect_item.connect('activate', self.__disconnect_activate_cb)
        self.menu_box.add(self._disconnect_item)

        p.set_content(self.menu_box)
        self.menu_box.show_all()

        self.connect_to_palette_pop_events(p)

        return p
开发者ID:ajaygarg84,项目名称:sugar,代码行数:29,代码来源:networkviews.py


示例6: __init__

    def __init__(self, name):
        Gtk.VBox.__init__(self)
        self._name = name

        self._notifications_box = Gtk.VBox()
        self._notifications_box.show()

        self._scrolled_window = Gtk.ScrolledWindow()
        self._scrolled_window.add_with_viewport(self._notifications_box)
        self._scrolled_window.set_policy(Gtk.PolicyType.NEVER,
                                         Gtk.PolicyType.AUTOMATIC)
        self._scrolled_window.show()

        separator = PaletteMenuItemSeparator()
        separator.show()

        clear_item = PaletteMenuItem(_('Clear notifications'), 'dialog-cancel')
        clear_item.connect('activate', self.__clear_cb)
        clear_item.show()

        self.add(self._scrolled_window)
        self.add(separator)
        self.add(clear_item)

        self._service = notifications.get_service()
        entries = self._service.retrieve_by_name(self._name)

        if entries:
            for entry in entries:
                self._add(entry['summary'], entry['body'])

        self._service.notification_received.connect(
            self.__notification_received_cb)

        self.connect('destroy', self.__destroy_cb)
开发者ID:jvonau,项目名称:sugar,代码行数:35,代码来源:notification.py


示例7: __init__

    def __init__(self, invite):
        Palette.__init__(self, '')

        self._invite = invite

        self.menu_box = PaletteMenuBox()
        self.set_content(self.menu_box)
        self.menu_box.show()

        menu_item = PaletteMenuItem(_('Join'), icon_name='dialog-ok')
        menu_item.connect('activate', self.__join_activate_cb)
        self.menu_box.append_item(menu_item)
        menu_item.show()

        menu_item = PaletteMenuItem(_('Decline'), icon_name='dialog-cancel')
        menu_item.connect('activate', self.__decline_activate_cb)
        self.menu_box.append_item(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)
开发者ID:icarito,项目名称:sugar,代码行数:29,代码来源:activitiestray.py


示例8: _refresh_resume_palette

    def _refresh_resume_palette(self):
        if self._metadata.get('activity_id', ''):
            # TRANS: Action label for resuming an activity.
            self._resume.set_tooltip(_('Resume'))
        else:
            # TRANS: Action label for starting an entry.
            self._resume.set_tooltip(_('Start'))

        palette = self._resume.get_palette()

        if self._resume_menu is not None:
            self._resume_menu.destroy()

        self._resume_menu = PaletteMenuBox()
        palette.set_content(self._resume_menu)
        self._resume_menu.show()

        for activity_info in misc.get_activities(self._metadata):
            menu_item = PaletteMenuItem(file_name=activity_info.get_icon(),
                                        text_label=activity_info.get_name())
            menu_item.connect('activate', self._resume_menu_item_activate_cb,
                              activity_info.get_bundle_id())
            self._resume_menu.append_item(menu_item)
            menu_item.show()

        if not misc.can_resume(self._metadata):
            self._resume.set_tooltip(_('No activity to start entry'))
开发者ID:AbrahmAB,项目名称:sugar,代码行数:27,代码来源:journaltoolbox.py


示例9: create_palette

    def create_palette(self):
        if not self._palette_enabled:
            self._palette_enabled = True
            return

        palette = BuddyMenu(get_owner_instance())

        settings = Gio.Settings('org.sugarlabs')
        if settings.get_boolean('show-register'):
            backup_url = settings.get_string('backup-url')

            if not backup_url:
                self._register_menu = PaletteMenuItem(_('Register'),
                                                      'media-record')
            else:
                self._register_menu = PaletteMenuItem(_('Register again'),
                                                      'media-record')

            self._register_menu.connect('activate',
                                        self.__register_activate_cb)
            palette.menu_box.pack_end(self._register_menu, True, True, 0)
            self._register_menu.show()

        self.connect_to_palette_pop_events(palette)

        return palette
开发者ID:salil93,项目名称:sugar,代码行数:26,代码来源:favoritesview.py


示例10: create_palette

    def create_palette(self):
        if not self._palette_enabled:
            self._palette_enabled = True
            return

        palette = BuddyMenu(get_owner_instance())

        client = GConf.Client.get_default()
        if client.get_bool('/desktop/sugar/show_register'):
            backup_url = client.get_string('/desktop/sugar/backup_url')

            if not backup_url:
                self._register_menu = PaletteMenuItem(_('Register'),
                                                      'media-record')
            else:
                self._register_menu = PaletteMenuItem(_('Register again'),
                                                      'media-record')

            self._register_menu.connect('activate',
                                        self.__register_activate_cb)
            palette.menu_box.pack_end(self._register_menu, True, True, 0)
            self._register_menu.show()

        self.connect_to_palette_pop_events(palette)

        return palette
开发者ID:ChristoferR,项目名称:sugar,代码行数:26,代码来源:favoritesview.py


示例11: __init__

    def __init__(self, text_label=None):
        PaletteMenuItem.__init__(self, text_label=None, text_maxlen=0)

        self.id_enter_notify_cb = self.connect('enter-notify-event',
                                               self.__enter_notify_cb)
        self.id_leave_notify_cb = self.connect('leave-notify-event',
                                               self.__leave_notify_cb)
        self.set_label(text_label)
开发者ID:AbrahmAB,项目名称:sugar,代码行数:8,代码来源:view.py


示例12: _add_erase_option

    def _add_erase_option(self, registry, activity_info):
        menu_item = PaletteMenuItem(_("Erase"), "list-remove")
        menu_item.connect("activate", self.__erase_activate_cb)
        self.menu_box.append_item(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:GhostAlgorithm,项目名称:sugar,代码行数:8,代码来源:activitieslist.py


示例13: create_menu_item

 def create_menu_item(history_item, item_index):
     """Create a MenuItem for the back or forward palettes."""
     title = history_item.get_title()
     if not isinstance(title, unicode):
         title = unicode(title, "utf-8")
     # This is a fix until the Sugar MenuItem is fixed:
     menu_item = PaletteMenuItem(text_label=title)
     menu_item.connect("activate", self._history_item_activated_cb, item_index)
     return menu_item
开发者ID:richaseh,项目名称:browse,代码行数:9,代码来源:webtoolbar.py


示例14: create_menu_item

 def create_menu_item(history_item):
     """Create a MenuItem for the back or forward palettes."""
     title = history_item.get_title() or _('No Title')
     if not isinstance(title, unicode):
         title = unicode(title, 'utf-8')
     # This is a fix until the Sugar MenuItem is fixed:
     menu_item = PaletteMenuItem(text_label=title)
     menu_item.connect('activate', self._history_item_activated_cb,
                       history_item)
     return menu_item
开发者ID:leonardcj,项目名称:browse-activity,代码行数:10,代码来源:webtoolbar.py


示例15: setup_palette

    def setup_palette(self):
        activity_name = self._home_activity.get_activity_name()
        if activity_name:
            self.props.primary_text = glib.markup_escape_text(activity_name)

        title = self._home_activity.get_title()
        if title and title != activity_name:
            self.props.secondary_text = glib.markup_escape_text(title)

        self.menu_box = PaletteMenuBox()

        menu_item = PaletteMenuItem(_('Resume'), 'activity-start')
        menu_item.connect('activate', self.__resume_activate_cb)
        self.menu_box.append_item(menu_item)

        # TODO: share-with, keep

        menu_item = PaletteMenuItem(_('View Source'), 'view-source')
        menu_item.connect('activate', self.__view_source__cb)
        self.menu_box.append_item(menu_item)

        separator = PaletteMenuItemSeparator()
        self.menu_box.append_item(separator)
        separator.show()

        menu_item = PaletteMenuItem(_('Stop'), 'activity-stop')
        menu_item.connect('activate', self.__stop_activate_cb)
        self.menu_box.append_item(menu_item)

        self.set_content(self.menu_box)
        self.menu_box.show_all()
开发者ID:ceibal-tatu,项目名称:sugar,代码行数:31,代码来源:palettes.py


示例16: _add_menu

 def _add_menu(self, option, icon=None, activate_cb=None):
     if icon is not None:
         menu_item = PaletteMenuItem(icon_name=icon)
         if activate_cb is not None:
             menu_item.connect('activate', activate_cb, [option, icon])
     else:
         menu_item = PaletteMenuItem()
         if activate_cb is not None:
             menu_item.connect('activate', activate_cb, option)
     menu_item.set_label(option)
     self._menu_box.append_item(menu_item)
     menu_item.show()
开发者ID:godiard,项目名称:domino-activity,代码行数:12,代码来源:palettebox.py


示例17: __init__

    def __init__(self, abi, abi_signal, do_abi_cb, icon_name, label,
                 button, on_abi_cb=None, button_icon_name=None):
        self._icon_name = icon_name
        # _button_icon_name is used only in the first case of
        # the list menu
        self._button_icon_name = button_icon_name
        self._button = button
        PaletteMenuItem.__init__(self, icon_name=icon_name, text_label=label)

        self._abi_handler = abi.connect(abi_signal, self.__abi_cb,
                                        abi_signal, on_abi_cb)
        self.connect('activate', self.__activated_cb, abi, do_abi_cb)
开发者ID:sugarlabs,项目名称:write-activity,代码行数:12,代码来源:widgets.py


示例18: OwnerIcon

class OwnerIcon(BuddyIcon):
    __gtype_name__ = 'SugarFavoritesOwnerIcon'

    __gsignals__ = {
        'register-activate': (GObject.SignalFlags.RUN_FIRST, None,
                              ([])),
    }

    def __init__(self, size):
        BuddyIcon.__init__(self, buddy=get_owner_instance(), pixel_size=size)

        self.palette_invoker.cache_palette = True

        self._palette_enabled = False
        self._register_menu = None

        # This is a workaround to skip the callback for
        # enter-notify-event in the parent class the first time.
        def __enter_notify_event_cb(icon, event):
            self.unset_state_flags(Gtk.StateFlags.PRELIGHT)
            self.disconnect(self._enter_notify_hid)

        self._enter_notify_hid = self.connect('enter-notify-event',
                                              __enter_notify_event_cb)

    def create_palette(self):
        if not self._palette_enabled:
            self._palette_enabled = True
            return

        palette = BuddyMenu(get_owner_instance())

        client = GConf.Client.get_default()
        backup_url = client.get_string('/desktop/sugar/backup_url')

        if not backup_url:
            self._register_menu = PaletteMenuItem(_('Register'),
                                                  'media-record')
        else:
            self._register_menu = PaletteMenuItem(_('Register again'),
                                                  'media-record')

        self._register_menu.connect('activate', self.__register_activate_cb)
        palette.menu_box.pack_end(self._register_menu, True, True, 0)
        self._register_menu.show()

        self.connect_to_palette_pop_events(palette)

        return palette

    def __register_activate_cb(self, menuitem):
        self.emit('register-activate')

    def set_registered(self):
        self.palette.menu_box.remove(self._register_menu)
        self._register_menu = PaletteMenuItem(_('Register again'),
                                              'media-record')
        self._register_menu.connect('activate', self.__register_activate_cb)
        self.palette.menu_box.pack_end(self._register_menu, True, True, 0)
        self._register_menu.show()
开发者ID:ajaygarg84,项目名称:sugar,代码行数:60,代码来源:favoritesview.py


示例19: __init__

    def __init__(self, url):
        Palette.__init__(self, url)
        self.owns_clipboard = False
        self.url = self._url_check_protocol(url)

        menu_box = Gtk.VBox()
        self.set_content(menu_box)
        menu_box.show()
        self._content.set_border_width(1)
        menu_item = PaletteMenuItem(_('Copy to Clipboard'), 'edit-copy')
        menu_item.connect('activate', self._copy_to_clipboard_cb)
        menu_box.pack_start(menu_item, False, False, 0)
        menu_item.show()
        self.props.invoker = ContentInvoker()
开发者ID:leonardcj,项目名称:speak,代码行数:14,代码来源:chatbox.py


示例20: __init__

    def __init__(self, file_name, document_path, activity_name, title,
                 bundle=False):
        RadioToolButton.__init__(self)

        self._document_path = document_path
        self._title = title
        self._jobject = None
        self._activity_name = activity_name

        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()

        box = PaletteMenuBox()
        self.props.palette.set_content(box)
        box.show()

        if bundle:
            menu_item = PaletteMenuItem(_('Duplicate'), 'edit-duplicate',
                                        xo_color=XoColor(self._color))
            menu_item.connect('activate', self.__show_duplicate_alert)
        else:
            menu_item = PaletteMenuItem(_('Keep'), 'document-save',
                                        xo_color=XoColor(self._color))
            menu_item.connect('activate', self.__keep_in_journal_cb)

        box.append_item(menu_item)
        menu_item.show()
开发者ID:sugarlabs,项目名称:sugar,代码行数:34,代码来源:viewsource.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python palettemenu.PaletteMenuItemSeparator类代码示例发布时间:2022-05-27
下一篇:
Python palettemenu.PaletteMenuBox类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap