本文整理匯總了Python中lollypop.radios.Radios.get方法的典型用法代碼示例。如果您正苦於以下問題:Python Radios.get方法的具體用法?Python Radios.get怎麽用?Python Radios.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lollypop.radios.Radios
的用法示例。
在下文中一共展示了Radios.get方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: next
# 需要導入模塊: from lollypop.radios import Radios [as 別名]
# 或者: from lollypop.radios.Radios import get [as 別名]
def next(self):
"""
Return next radio name, uri
@return Track
"""
track = Track()
if self.current_track.id != Type.RADIOS:
return track
radios_manager = Radios()
radios = radios_manager.get()
i = 0
for (name, url) in radios:
i += 1
if self.current_track.album_artist == name:
break
# Get next radio
if i >= len(radios):
i = 0
name = radios[i][0]
url = radios[i][1]
if url:
track.set_radio(name, url)
return track
示例2: prev
# 需要導入模塊: from lollypop.radios import Radios [as 別名]
# 或者: from lollypop.radios.Radios import get [as 別名]
def prev(self):
"""
Return prev radio name, uri
@return Track
"""
track = Track()
if self.current_track.id != Type.RADIOS:
return track
radios_manager = Radios()
radios = radios_manager.get()
i = len(radios) - 1
for (name, url) in reversed(radios):
i -= 1
if self.current_track.album_artist == name:
break
# Get prev radio
if i < 0:
i = len(radios) - 1
name = radios[i][0]
url = radios[i][1]
if url:
track.set_radio(name, url)
return track
示例3: RadiosView
# 需要導入模塊: from lollypop.radios import Radios [as 別名]
# 或者: from lollypop.radios.Radios import get [as 別名]
class RadiosView(View):
"""
Show radios in a grid
"""
def __init__(self):
"""
Init view
"""
View.__init__(self)
self._signal = Lp().art.connect('radio-artwork-changed',
self._on_logo_changed)
self._radios_manager = Radios()
self._radios_manager.connect('radios-changed',
self._on_radios_changed)
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/RadiosView.ui')
builder.connect_signals(self)
widget = builder.get_object('widget')
self._empty = builder.get_object('empty')
self._pop_tunein = TuneinPopover(self._radios_manager)
self._pop_tunein.set_relative_to(builder.get_object('search_btn'))
self._sizegroup = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.BOTH)
self._radiobox = Gtk.FlowBox()
self._radiobox.set_selection_mode(Gtk.SelectionMode.NONE)
self._radiobox.connect("child-activated", self._on_album_activated)
self._radiobox.set_property('column-spacing', 5)
self._radiobox.set_property('row-spacing', 5)
self._radiobox.set_homogeneous(True)
self._radiobox.set_max_children_per_line(1000)
self._radiobox.show()
self._stack = Gtk.Stack()
self._stack.set_transition_duration(500)
self._stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
self._stack.add(self._scrolled)
self._stack.add(self._empty)
self._stack.show()
self._viewport.set_property("valign", Gtk.Align.START)
self._viewport.set_property('margin', 5)
self._viewport.add(self._radiobox)
self._scrolled.set_property('expand', True)
self.add(widget)
self.add(self._stack)
def populate(self):
"""
Populate view with tracks from playlist
Thread safe
"""
Lp().player.set_radios(self._radios_manager.get())
if Lp().player.current_track.id == Type.RADIOS:
Lp().player.set_next() # We force next update
Lp().player.set_prev() # We force prev update
t = Thread(target=self._populate)
t.daemon = True
t.start()
#######################
# PRIVATE #
#######################
def _populate(self):
"""
Populate view with tracks from playlist
Thread safe
"""
radios = []
# Get radios name
for (name, url) in self._radios_manager.get():
radios.append(name)
GLib.idle_add(self._show_stack, radios)
def _get_children(self):
"""
Return view children
@return [RadioWidget]
"""
children = []
for child in self._radiobox.get_children():
widget = child.get_child()
children.append(widget)
return children
def _on_destroy(self, widget):
"""
Disconnect signals
@param widget as Gtk.Widget
"""
if self._signal is not None:
Lp().art.disconnect(self._signal)
def _on_new_clicked(self, widget):
"""
Show popover for adding a new radio
#.........這裏部分代碼省略.........