本文整理汇总了Python中lollypop.view_container.ViewContainer.add_named方法的典型用法代码示例。如果您正苦于以下问题:Python ViewContainer.add_named方法的具体用法?Python ViewContainer.add_named怎么用?Python ViewContainer.add_named使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lollypop.view_container.ViewContainer
的用法示例。
在下文中一共展示了ViewContainer.add_named方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import add_named [as 别名]
#.........这里部分代码省略.........
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)
def _update_view_albums(self, genre_id, is_compilation=False):
"""
示例2: __init__
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import add_named [as 别名]
#.........这里部分代码省略.........
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()
self._stack.add(view)
self._stack.set_visible_child(view)
self._stack.clean_old_views(view)
示例3: __init__
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import add_named [as 别名]
#.........这里部分代码省略.........
"""
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)
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)