本文整理匯總了Python中lollypop.radios.Radios.add方法的典型用法代碼示例。如果您正苦於以下問題:Python Radios.add方法的具體用法?Python Radios.add怎麽用?Python Radios.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lollypop.radios.Radios
的用法示例。
在下文中一共展示了Radios.add方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TuneinPopover
# 需要導入模塊: from lollypop.radios import Radios [as 別名]
# 或者: from lollypop.radios.Radios import add [as 別名]
class TuneinPopover(Gtk.Popover):
"""
Popover showing tunin radios
"""
def __init__(self, radios_manager=None):
"""
Init Popover
@param radios_manager as Radios
"""
Gtk.Popover.__init__(self)
self._tunein = TuneIn()
if radios_manager is not None:
self._radios_manager = radios_manager
else:
self._radios_manager = Radios()
self._current_url = None
self._timeout_id = None
self._previous_urls = []
self._covers_to_download = []
self._stack = Gtk.Stack()
self._stack.set_property('expand', True)
self._stack.show()
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/TuneinPopover.ui')
builder.connect_signals(self)
widget = builder.get_object('widget')
widget.attach(self._stack, 0, 2, 5, 1)
self._back_btn = builder.get_object('back_btn')
self._home_btn = builder.get_object('home_btn')
self._label = builder.get_object('label')
self._view = Gtk.FlowBox()
self._view.set_selection_mode(Gtk.SelectionMode.NONE)
self._view.set_max_children_per_line(100)
self._view.set_property('row-spacing', 10)
self._view.set_property('expand', True)
self._view.show()
self._spinner = builder.get_object('spinner')
builder.get_object('viewport').add(self._view)
builder.get_object('viewport').set_property('margin', 10)
self._scrolled = builder.get_object('scrolled')
self._stack.add_named(self._spinner, 'spinner')
self._stack.add_named(builder.get_object('notfound'), 'notfound')
self._stack.add_named(self._scrolled, 'scrolled')
self.add(widget)
self.connect('map', self._on_map)
self.connect('unmap', self._on_unmap)
def populate(self, url=None):
"""
Populate views
@param url as string
"""
if url is None and self._current_url is not None:
return
self._spinner.start()
self._clear()
self._stack.set_visible_child_name('spinner')
self._current_url = url
self._back_btn.set_sensitive(False)
self._home_btn.set_sensitive(False)
self._label.set_text(_("Please wait..."))
t = Thread(target=self._populate, args=(url,))
t.daemon = True
t.start()
#######################
# PRIVATE #
#######################
def _show_not_found(self, message=""):
"""
Show not found message
@param message as str
"""
# TODO Add a string
self._label.set_text(message)
self._stack.set_visible_child_name('notfound')
self._home_btn.set_sensitive(True)
def _populate(self, url):
"""
Same as populate()
@param url as string
@thread safe
"""
try:
if url is None:
items = self._tunein.get_items(
"http://opml.radiotime.com/Browse.ashx?c=")
else:
items = self._tunein.get_items(url)
if self._current_url == url:
#.........這裏部分代碼省略.........
示例2: TuneinPopover
# 需要導入模塊: from lollypop.radios import Radios [as 別名]
# 或者: from lollypop.radios.Radios import add [as 別名]
class TuneinPopover(Gtk.Popover):
"""
Popover showing tunin radios
"""
def __init__(self, radios_manager=None):
"""
Init Popover
@param radios_manager as Radios
"""
Gtk.Popover.__init__(self)
self._tunein = TuneIn()
if radios_manager is not None:
self._radios_manager = radios_manager
else:
self._radios_manager = Radios()
self._current_url = None
self._previous_urls = []
self._stack = Gtk.Stack()
self._stack.set_property('expand', True)
self._stack.show()
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/TuneinPopover.ui')
builder.connect_signals(self)
widget = builder.get_object('widget')
widget.attach(self._stack, 0, 2, 4, 1)
self._back_btn = builder.get_object('back_btn')
self._home_btn = builder.get_object('home_btn')
self._label = builder.get_object('label')
self._view = Gtk.FlowBox()
self._view.set_selection_mode(Gtk.SelectionMode.NONE)
self._view.set_max_children_per_line(100)
self._view.set_property('row-spacing', 10)
self._view.set_property('expand', True)
self._view.show()
builder.get_object('viewport').add(self._view)
builder.get_object('viewport').set_property('margin', 10)
self._scrolled = builder.get_object('scrolled')
self._stack.add_named(builder.get_object('spinner'), 'spinner')
self._stack.add_named(builder.get_object('notfound'), 'notfound')
self._stack.add_named(self._scrolled, 'scrolled')
self._stack.set_visible_child_name('spinner')
self.add(widget)
size_setting = Lp().settings.get_value('window-size')
if isinstance(size_setting[1], int):
self.set_size_request(700, size_setting[1]*0.7)
else:
self.set_size_request(700, 400)
def populate(self, url=None):
"""
Populate views
@param url as string
"""
if not self._view.get_children():
self._current_url = url
self._clear()
self._back_btn.set_sensitive(False)
self._home_btn.set_sensitive(False)
self._label.set_text(_("Please wait..."))
t = Thread(target=self._populate, args=(url,))
t.daemon = True
t.start()
#######################
# PRIVATE #
#######################
def _show_not_found(self):
"""
Show not found message
"""
self._label.set_text(_("Can't connect to TuneIn..."))
self._stack.set_visible_child_name('notfound')
self._home_btn.set_sensitive(True)
def _populate(self, url):
"""
Same as populate()
@param url as string
@thread safe
"""
if url is None:
items = self._tunein.get_items()
else:
items = self._tunein.get_items(url)
if items:
self._add_items(items)
else:
GLib.idle_add(self._show_not_found)
def _add_items(self, items):
"""
Add current items
#.........這裏部分代碼省略.........