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


Python Menu.action_helper方法代码示例

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


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

示例1: albums_action

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import action_helper [as 别名]
        def albums_action(menuitem, gui, artist_id = None):
            """
            Load the list of artists from the XBMC and display the menu.
            """
            
            if artist_id:
                result = xbmc.call.AudioLibrary.GetAlbums(artistid = artist_id)
            else:
                result = xbmc.call.AudioLibrary.GetAlbums()

            def convert(album):
                text = album["label"]
                if album.has_key('thumbnail'):
                    pass
                    #image = self.cache.open_http(
                    #    album["thumbnail"], self.config["default album"],
                    #    image_convert)
                else:
                    image = self.cache.open(self.config["default album"])

                def action(menuitem2, gui2):
                    tracks_action(menuitem2, gui2, album["albumid"])

                return MenuItem(image, text, action)

            self.albums_menu.fill(*map(convert, result["albums"]))
            Menu.action_helper(self.albums_menu)(menuitem, gui)
开发者ID:bluecube,项目名称:TouchBMC,代码行数:29,代码来源:menu_impl.py

示例2: artists_action

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import action_helper [as 别名]
        def artists_action(menuitem, gui):
            """
            Load the list of artists from the XBMC and display the menu.
            """
            
            result = xbmc.call.AudioLibrary.GetArtists()

            def convert(artist):
                text = artist["label"]
                if artist.has_key('thumbnail'):
                    image = self.cache.open_http(
                        artist["thumbnail"], self.config["default artist"],
                        image_convert)
                else:
                    image = self.cache.open(self.config["default artist"])

                def action(menuitem2, gui2):
                    albums_action(menuitem2, gui2, artist["artistid"])

                return MenuItem(image, text, action)

            self.artists_menu.fill(*map(convert, result["artists"]))
            Menu.action_helper(self.artists_menu)(menuitem, gui)
开发者ID:bluecube,项目名称:TouchBMC,代码行数:25,代码来源:menu_impl.py

示例3: __init__

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import action_helper [as 别名]
    def __init__(self, config, xbmc):
        self.config = config

        self.albums_menu = Menu(config)
        self.artists_menu = Menu(config)

#        def image_convert(image):
#            """
#            Change the image to the correct size
#            """
# 
#            allowed_width = int(config["item distance"] * 0.9)
#            allowed_height = int(config["height"] * 0.5)
#            
#            if image.get_width() < allowed_width and image.get_height < allowed_height:
#                return image.convert_alpha()
# 
#            aspect = image.get_width() / float(image.get_height())
#            allowed_aspect = allowed_width / float(allowed_height)
# 
#            if aspect > allowed_aspect:
#                width = allowed_width
#                height = int(allowed_width / aspect)
#            else:
#                width = int(allowed_height * aspect)
#                height = allowed_height
# 
#            image = pygame.transform.smoothscale(image, (width, height))
#            return image.convert_alpha()

        def tracks_action(menuitem, gui, album_id = None):
            pass

        def albums_action(menuitem, gui, artist_id = None):
            """
            Load the list of artists from the XBMC and display the menu.
            """
            
            if artist_id:
                result = xbmc.call.AudioLibrary.GetAlbums(artistid = artist_id)
            else:
                result = xbmc.call.AudioLibrary.GetAlbums()

            def convert(album):
                text = album["label"]
                if album.has_key('thumbnail'):
                    pass
                    #image = self.cache.open_http(
                    #    album["thumbnail"], self.config["default album"],
                    #    image_convert)
                else:
                    image = self.cache.open(self.config["default album"])

                def action(menuitem2, gui2):
                    tracks_action(menuitem2, gui2, album["albumid"])

                return MenuItem(image, text, action)

            self.albums_menu.fill(*map(convert, result["albums"]))
            Menu.action_helper(self.albums_menu)(menuitem, gui)

        def artists_action(menuitem, gui):
            """
            Load the list of artists from the XBMC and display the menu.
            """
            
            result = xbmc.call.AudioLibrary.GetArtists()

            def convert(artist):
                text = artist["label"]
                if artist.has_key('thumbnail'):
                    image = self.cache.open_http(
                        artist["thumbnail"], self.config["default artist"],
                        image_convert)
                else:
                    image = self.cache.open(self.config["default artist"])

                def action(menuitem2, gui2):
                    albums_action(menuitem2, gui2, artist["artistid"])

                return MenuItem(image, text, action)

            self.artists_menu.fill(*map(convert, result["artists"]))
            Menu.action_helper(self.artists_menu)(menuitem, gui)
        
        def poweroff_action(menuitem, gui):
            gui.go_back()
            xbmc.call.System.Suspend()

        def playpause_action(menuitem, gui):
            state = ()
            print state
        
        self.power_menu = Menu(
            MenuItem(config["shutdown"], "Power off", poweroff_action),
            MenuItem(config["exit"], "Exit", lambda menuitem, gui: sys.exit()),
        )

        self.library_menu = Menu(
            MenuItem(config["artists"], "Artists ...", artists_action),
#.........这里部分代码省略.........
开发者ID:bluecube,项目名称:TouchBMC,代码行数:103,代码来源:menu_impl.py


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