本文整理汇总了Python中kivy.uix.slider.Slider.width方法的典型用法代码示例。如果您正苦于以下问题:Python Slider.width方法的具体用法?Python Slider.width怎么用?Python Slider.width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.slider.Slider
的用法示例。
在下文中一共展示了Slider.width方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_contents
# 需要导入模块: from kivy.uix.slider import Slider [as 别名]
# 或者: from kivy.uix.slider.Slider import width [as 别名]
def setup_contents(self):
x = self.x
center_y = self.center_y
top = self.top
# data_width = 600
# data_x = 10
# data_text_height = 15
#create objects
title_label = Label(text="Waiting", size_hint=(None, None))
artist_label = Label(text="Waiting", size_hint=(None, None))
album_label = Label(text="Waiting", size_hint=(None, None))
playtime_label = Label(text="00:00", size_hint=(None, None))
length_label = Label(text="00:00", size_hint=(None, None))
playback_slider = Slider(min=0, max=0, value=0, size_hint=(None, None))
next_btn = Button(text="Waiting", size_hint=(None, None))
prev_btn = Button(text="Waiting", size_hint=(None, None))
play_btn = Button(text="Waiting", size_hint=(None, None))
# vol_up_btn = Button(text="Waiting", size_hint=(None, None))
# vol_down_btn = Button(text="Waiting", size_hint=(None, None))
#layout the objects
padding_x = 5
padding_y = 1
btn_dim = 75
btn_size = (btn_dim, btn_dim)
play_btn.size = btn_size
next_btn.size = btn_size
prev_btn.size = btn_size
play_btn.x = x + padding_x
play_btn.center_y = center_y
prev_btn.x = x + padding_x * 2 + btn_dim
prev_btn.center_y = center_y
next_btn.x = x + padding_x * 3 + btn_dim * 2
next_btn.center_y = center_y
# vol_up_btn.size = btn_size
# vol_down_btn.size = btn_size
# vol_up_btn.x = x + padding_x * 4 + btn_dim * 3
# vol_up_btn.center_y = center_y
# vol_down_btn.x = x + padding_x * 5 + btn_dim * 4
# vol_down_btn.center_y = center_y
data_x = x + padding_x * 4 + btn_dim * 3
# data_x = x + padding_x * 6 + btn_dim * 5
data_width = self.width - data_x
text_height = 15
time_width = 40
slider_height = 30
slider_center_y = top - padding_y * 4 - text_height * 3 - slider_height / 2.0
title_label.pos = (data_x + padding_x, top - (padding_y + text_height) * 1)
title_label.size = (data_width - 2 * padding_x, text_height)
artist_label.pos = (data_x + padding_x, top - (padding_y + text_height) * 2)
artist_label.size = (data_width - 2 * padding_x, text_height)
album_label.pos = (data_x + padding_x, top - (padding_y + text_height) * 3)
album_label.size = (data_width - 2 * padding_x, text_height)
playtime_label.size = (time_width, text_height)
playtime_label.x = data_x + padding_x
playtime_label.center_y = slider_center_y
length_label.size = (time_width, text_height)
length_label.right = data_x + data_width - padding_x
length_label.center_y = slider_center_y
playback_slider.width = length_label.x - padding_x * 2 - playtime_label.right
playback_slider.height = slider_height
playback_slider.x = playtime_label.right + padding_x
playback_slider.center_y = slider_center_y
#add the objects
self._add_widget(play_btn)
self._add_widget(prev_btn)
self._add_widget(next_btn)
self._add_widget(title_label)
self._add_widget(artist_label)
self._add_widget(album_label)
self._add_widget(playtime_label)
self._add_widget(length_label)
self._add_widget(playback_slider)
playback_slider.bind(on_touch_up=self.slider_touch_up, on_touch_down=self.slider_touch_down)
playback_slider.bind(value=self._update_playtime_label)
play_btn.bind(on_press=self.play_pause_track)
next_btn.bind(on_press=self.next_track)
prev_btn.bind(on_press=self.prev_track)
vol_up_btn.bind(on_press=self.vol_up)
vol_down_btn.bind(on_press=self.vol_down)
#store objects to self
self.play_btn = play_btn
self.prev_btn = prev_btn
self.next_btn = next_btn
#.........这里部分代码省略.........