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


Python MenuItem.set_label方法代码示例

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


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

示例1: refresh_activity_list

# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import set_label [as 别名]
    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()
开发者ID:sugarlabs,项目名称:sugar-launcher-applet,代码行数:37,代码来源:launcher.py

示例2: process_dir

# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import set_label [as 别名]
        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)
开发者ID:sugarlabs,项目名称:sugar-launcher-applet,代码行数:16,代码来源:launcher.py

示例3: make_submenu

# 需要导入模块: from sugar3.graphics.menuitem import MenuItem [as 别名]
# 或者: from sugar3.graphics.menuitem.MenuItem import set_label [as 别名]
    def make_submenu(self, bundle):
        submenu = Gtk.Menu()

        newitem = MenuItem(icon_name='activity-start')
        newitem.set_label("Start new")
        newitem.connect("activate", self.launch, bundle)
        submenu.append(newitem)

        results, n = _datastore.find(
                            {'limit':10, 
                             'activity':bundle.get_bundle_id()},
                            ['uid', 'title', 'mime_type'])

        if n>0:
            separator = Gtk.SeparatorMenuItem()
            submenu.append(separator)

        for i in results:
            title = ''.join([chr(byte) for byte in i['title']])
            uid = i['uid']

            item = MenuItem(file_name=bundle.get_icon(),
                            xo_color=xocolor.XoColor())
            item.set_label(title)
            item.connect("activate", self.launch_with_uid, bundle, uid)
            submenu.append(item)

        if n>0:
            separator = Gtk.SeparatorMenuItem()
            submenu.append(separator)

        view_source = MenuItem(icon_name='view-source')
        view_source.set_label("View Source")
        view_source.connect("activate", self.view_source, bundle)
        submenu.append(view_source)

        return submenu
开发者ID:sugarlabs,项目名称:sugar-launcher-applet,代码行数:39,代码来源:launcher.py


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