當前位置: 首頁>>代碼示例>>Python>>正文


Python Track.formated_name方法代碼示例

本文整理匯總了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)
開發者ID:sgnls,項目名稱:lollypop,代碼行數:25,代碼來源:widgets_track.py

示例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:
#.........這裏部分代碼省略.........
開發者ID:ktkr3d,項目名稱:lollypop,代碼行數:103,代碼來源:widgets_track.py


注:本文中的lollypop.objects.Track.formated_name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。