本文整理汇总了Python中lollypop.objects.Track.formated_name方法的典型用法代码示例。如果您正苦于以下问题:Python Track.formated_name方法的具体用法?Python Track.formated_name怎么用?Python Track.formated_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lollypop.objects.Track
的用法示例。
在下文中一共展示了Track.formated_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_row
# 需要导入模块: from lollypop.objects import Track [as 别名]
# 或者: from lollypop.objects.Track import formated_name [as 别名]
def set_row(self, row, track_id, pos, show_cover=False):
"""
Set row content
@param row as Row
@param track id as int
@param pos as position
@param show cover as bool
"""
track = Track(track_id)
row.show_indicator(Lp().player.current_track.id == track_id,
utils.is_loved(track_id))
row.set_number(pos)
self._update_pos_label(row, track_id)
row.set_title_label(track.formated_name())
row.set_duration_label(seconds_to_string(track.duration))
row.set_id(track_id)
if show_cover:
surface = Lp().art.get_album_artwork(
track.album,
ArtSize.MEDIUM*row.get_scale_factor())
row.set_cover(surface, track.album.name)
del surface
row.show_header(True)
示例2: Row
# 需要导入模块: from lollypop.objects import Track [as 别名]
# 或者: from lollypop.objects.Track import formated_name [as 别名]
class Row(Gtk.ListBoxRow):
"""
A row
"""
def __init__(self, rowid, num):
"""
Init row widgets
@param rowid as int
@param num as int
@param show loved as bool
"""
# We do not use Gtk.Builder for speed reasons
Gtk.ListBoxRow.__init__(self)
self._track = Track(rowid)
self._number = num
self._indicator = IndicatorWidget(self._track.id)
self.set_indicator(Lp().player.current_track.id == self._track.id,
utils.is_loved(self._track.id))
self._row_widget = Gtk.EventBox()
self._row_widget.connect('button-press-event', self._on_button_press)
self._row_widget.connect('enter-notify-event', self._on_enter_notify)
self._grid = Gtk.Grid()
self._grid.set_column_spacing(5)
self._row_widget.add(self._grid)
self._title_label = Gtk.Label.new(self._track.formated_name())
self._title_label.set_use_markup(True)
self._title_label.set_property('has-tooltip', True)
self._title_label.connect('query-tooltip',
self._on_title_query_tooltip)
self._title_label.set_property('hexpand', True)
self._title_label.set_property('halign', Gtk.Align.START)
self._title_label.set_ellipsize(Pango.EllipsizeMode.END)
self._duration_label = Gtk.Label.new(
seconds_to_string(self._track.duration))
self._duration_label.get_style_context().add_class('dim-label')
self._num_label = Gtk.Label()
self._num_label.set_ellipsize(Pango.EllipsizeMode.END)
self._num_label.set_property('valign', Gtk.Align.CENTER)
self._num_label.set_width_chars(4)
self._num_label.get_style_context().add_class('dim-label')
self.update_num_label()
self._menu_button = Gtk.Button.new()
# Here a hack to make old Gtk version support min-height css attribute
# min-height = 24px, borders = 2px, we set directly on stack
# min-width = 24px, borders = 2px, padding = 8px
self._menu_button.set_size_request(34, 26)
self._menu_button.set_relief(Gtk.ReliefStyle.NONE)
self._menu_button.get_style_context().add_class('menu-button')
self._menu_button.get_style_context().add_class('track-menu-button')
self._grid.add(self._num_label)
self._grid.add(self._title_label)
self._grid.add(self._duration_label)
# TODO Remove this later
if Gtk.get_minor_version() > 16:
self._grid.add(self._menu_button)
else:
self.connect('map', self._on_map)
self.add(self._row_widget)
self.get_style_context().add_class('trackrow')
def set_indicator(self, playing, loved):
"""
Show indicator
@param widget name as str
@param playing as bool
@param loved as bool
"""
self._indicator.clear()
if playing:
self.get_style_context().remove_class('trackrow')
self.get_style_context().add_class('trackrowplaying')
if loved:
self._indicator.play_loved()
else:
self._indicator.play()
else:
self.get_style_context().remove_class('trackrowplaying')
self.get_style_context().add_class('trackrow')
if loved:
self._indicator.loved()
else:
self._indicator.empty()
def set_number(self, num):
"""
Set number
@param number as int
"""
self._number = num
def update_num_label(self):
"""
Update position label for row
"""
if Lp().player.is_in_queue(self._track.id):
self._num_label.get_style_context().add_class('queued')
pos = Lp().player.get_track_position(self._track.id)
self._num_label.set_text(str(pos))
elif self._number > 0:
#.........这里部分代码省略.........