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


Python ViewContainer.get_child_by_name方法代码示例

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


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

示例1: __init__

# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import get_child_by_name [as 别名]

#.........这里部分代码省略.........
                self._list_two.hide()
            self._list_two_restore = Type.NONE
        loader = Loader(target=load, view=selection_list,
                        on_finished=lambda r: setup(*r))
        loader.start()

    def _setup_list_playlists(self, update):
        """
            Setup list for playlists
            @param update as bool
            @thread safe
        """
        playlists = [(Type.LOVED, Lp.playlists._LOVED)]
        playlists += [(Type.POPULARS, _("Popular tracks"))]
        playlists += [(Type.RECENTS, _("Recently played"))]
        playlists += [(Type.NEVER, _("Never played"))]
        playlists += [(Type.RANDOMS, _("Random tracks"))]
        playlists.append((Type.SEPARATOR, ''))
        playlists += Lp.playlists.get()
        if update:
            self._list_two.update_values(playlists)
        else:
            self._list_two.mark_as_artists(False)
            self._list_two.populate(playlists)

    def _update_view_device(self, device_id):
        """
            Update current view with device view,
            Use existing view if available
            @param device id as int
        """
        device = self._devices[device_id]

        child = self._stack.get_child_by_name(device.uri)
        if child is None:
            child = DeviceView(device, self._progress)
            self._stack.add_named(child, device.uri)
            child.show()
        child.populate()
        self._stack.set_visible_child(child)
        self._stack.clean_old_views(child)

    def _update_view_artists(self, artist_id, genre_id):
        """
            Update current view with artists view
            @param artist id as int
            @param genre id as int
        """
        def load():
            sql = Lp.db.get_cursor()
            if artist_id == Type.COMPILATIONS:
                albums = Lp.albums.get_compilations(genre_id, sql)
            elif genre_id == Type.ALL:
                albums = Lp.albums.get_ids(artist_id, None, sql)
            else:
                albums = Lp.albums.get_ids(artist_id, genre_id, sql)
            sql.close()
            return albums

        view = ArtistView(artist_id, genre_id)
        loader = Loader(target=load, view=view)
        loader.start()
        view.show()
        self._stack.add(view)
        self._stack.set_visible_child(view)
        self._stack.clean_old_views(view)
开发者ID:sebfag,项目名称:lollypop,代码行数:70,代码来源:container.py

示例2: __init__

# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import get_child_by_name [as 别名]

#.........这里部分代码省略.........
            if self._list_two.is_visible():
                self._list_two.hide()
            self._list_two_restore = Type.NONE
        loader = Loader(target=load, view=selection_list,
                        on_finished=lambda r: setup(*r))
        loader.start()

    def _setup_list_playlists(self, update):
        """
            Setup list for playlists
            @param update as bool
            @thread safe
        """
        playlists = [(Type.LOVED, Lp().playlists._LOVED)]
        playlists.append((Type.POPULARS, _("Popular tracks")))
        playlists.append((Type.RECENTS, _("Recently played")))
        playlists.append((Type.NEVER, _("Never played")))
        playlists.append((Type.RANDOMS, _("Random tracks")))
        playlists.append((Type.SEPARATOR, ''))
        playlists += Lp().playlists.get()
        if update:
            self._list_two.update_values(playlists)
        else:
            self._list_two.mark_as_artists(False)
            self._list_two.populate(playlists)

    def _update_view_device(self, device_id):
        """
            Update current view with device view,
            Use existing view if available
            @param device id as int
        """
        device = self._devices[device_id]
        child = self._stack.get_child_by_name(device.uri)
        if child is None:
            if DeviceView.get_files(device.uri):
                child = DeviceView(device, self._progress)
                self._stack.add_named(child, device.uri)
            else:
                child = DeviceLocked()
                self._stack.add(child)
            child.show()
        child.populate()
        self._stack.set_visible_child(child)
        self._stack.clean_old_views(child)

    def _update_view_artists(self, genre_ids, artist_ids):
        """
            Update current view with artists view
            @param genre ids as [int]
            @param artist ids as [int]
        """
        def load():
            if genre_ids and genre_ids[0] == Type.ALL:
                albums = Lp().albums.get_ids(artist_ids, [])
            else:
                albums = []
                if artist_ids and artist_ids[0] == Type.COMPILATIONS:
                    albums += Lp().albums.get_compilations(genre_ids)
                albums += Lp().albums.get_ids(artist_ids, genre_ids)
            return albums

        view = ArtistView(artist_ids, genre_ids)
        loader = Loader(target=load, view=view)
        loader.start()
        view.show()
开发者ID:ktkr3d,项目名称:lollypop,代码行数:70,代码来源:container.py

示例3: __init__

# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import get_child_by_name [as 别名]

#.........这里部分代码省略.........

    def __update_list_playlists(self, update):
        """
            Setup list for playlists
            @param update as bool
            @thread safe
        """
        items = self.__list_two.get_pl_headers()
        items += Lp().playlists.get()
        if update:
            self.__list_two.update_values(items)
        else:
            self.__list_two.mark_as_artists(False)
            self.__list_two.populate(items)

    def __stop_current_view(self):
        """
            Stop current view
        """
        child = self.__stack.get_visible_child()
        if child is not None:
            if hasattr(child, "stop"):
                child.stop()

    def __update_view_device(self, device_id):
        """
            Update current view with device view,
            Use existing view if available
            @param device id as int
        """
        from lollypop.view_device import DeviceView, DeviceLocked
        self.__stop_current_view()
        device = self.__devices[device_id]
        child = self.__stack.get_child_by_name(device.uri)
        if child is None:
            files = DeviceView.get_files(device.uri)
            if files:
                if child is None:
                    child = DeviceView(device)
                    self.__stack.add_named(child, device.uri)
            else:
                child = DeviceLocked()
                self.__stack.add(child)
            child.show()
        child.populate()
        self.__stack.set_visible_child(child)
        self.__stack.clean_old_views(child)

    def __update_view_artists(self, genre_ids, artist_ids):
        """
            Update current view with artists view
            @param genre ids as [int]
            @param artist ids as [int]
        """
        def load():
            if genre_ids and genre_ids[0] == Type.ALL:
                albums = Lp().albums.get_ids(artist_ids, [])
            else:
                albums = []
                if artist_ids and artist_ids[0] == Type.COMPILATIONS:
                    albums += Lp().albums.get_compilation_ids(genre_ids)
                albums += Lp().albums.get_ids(artist_ids, genre_ids)
            return albums
        from lollypop.view_artist import ArtistView
        self.__stop_current_view()
        view = ArtistView(artist_ids, genre_ids)
开发者ID:TainakaDrums,项目名称:lollypop,代码行数:70,代码来源:container.py


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