本文整理汇总了Python中kivy.uix.slider.Slider.bind方法的典型用法代码示例。如果您正苦于以下问题:Python Slider.bind方法的具体用法?Python Slider.bind怎么用?Python Slider.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.slider.Slider
的用法示例。
在下文中一共展示了Slider.bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build
# 需要导入模块: from kivy.uix.slider import Slider [as 别名]
# 或者: from kivy.uix.slider.Slider import bind [as 别名]
def build(self):
from kivy.uix.slider import Slider
def test(*ars):
gauge.value = s.value
print(s.value)
def test_(*ars):
gauge_.value = s1.value
print(s.value)
box = BoxLayout(orientation='vertical', spacing=10, padding=10)
gauge = Gauge(value=50, size_gauge=256, size_text=9)
gauge_ = Gauge(value=50, size_gauge=256, size_text=19)
box.add_widget(gauge)
box.add_widget(gauge_)
s = Slider(min=0, max=100, value=50)
s.bind(value=test)
box.add_widget(s)
s1 = Slider(min=0, max=100, value=50)
s1.bind(value=test_)
box.add_widget(s1)
return box
示例2: build
# 需要导入模块: from kivy.uix.slider import Slider [as 别名]
# 或者: from kivy.uix.slider.Slider import bind [as 别名]
def build(self):
main_layout = BoxLayout(orientation='horizontal')
oil_layout = BoxLayout(orientation='vertical')
water_layout = BoxLayout(orientation='vertical')
oil_label = Label(text='Öl', size_hint = (1, None), font_size = 30)
oil_temp_label = Label(text='20 °C', size_hint = (1, None), font_size = 30)
self.oil_temp_label = oil_temp_label
oil_slider = Slider(min = 0, max = 150, value = 20, orientation = 'vertical')
self.oil_slider = oil_slider
oil_slider.bind(value=self.on_oil_slider)
oil_layout.add_widget(oil_label)
oil_layout.add_widget(oil_slider)
oil_layout.add_widget(oil_temp_label)
water_label = Label(text='Wasser', size_hint = (1, None), font_size = 30)
water_temp_label = Label(text='10 °C', size_hint = (1, None), font_size = 30)
self.water_temp_label = water_temp_label
water_slider = Slider(min = 0, max = 40, value = 10, orientation = 'vertical')
self.water_slider = water_slider
water_slider.bind(value=self.on_water_slider)
water_layout.add_widget(water_label)
water_layout.add_widget(water_slider)
water_layout.add_widget(water_temp_label)
main_layout.add_widget(oil_layout)
main_layout.add_widget(water_layout)
return main_layout
示例3: SliderulMeu
# 需要导入模块: from kivy.uix.slider import Slider [as 别名]
# 或者: from kivy.uix.slider.Slider import bind [as 别名]
class SliderulMeu(GridLayout):
def __init__(self, **kwargs):
super(SliderulMeu, self).__init__(**kwargs)
self.cols = 1
self.padding = 150
self.toggle1 = ToggleButton(text="muzica")
self.toggle1.background_normal = "on.png"
self.toggle1.background_down = "off.png"
self.add_widget(self.toggle1)
self.arata_volum = Label (text = "volum: 10")
self.add_widget(self.arata_volum)
self.slide_muzica = Slider(min=0, max=100, value=10)
self.slide_muzica.step = 5
self.slide_muzica.orientation="horizontal" # alte optiuni 'vertical'
self.add_widget(self.slide_muzica)
self.toggle1.bind(on_press=self.dezactiveaza_volum)
self.slide_muzica.bind(value=self.valoare_volum)
def valoare_volum (self,x,y):
'''utilziat pentru a vedea volumul'''
self.arata_volum.text = "volum: "+str(int(self.slide_muzica.value))
def dezactiveaza_volum (self,x):
'''utilziat pentru a acctiva sau a dezactiva slider-ul'''
if (self.toggle1.state == "down") :
self.slide_muzica.disabled =True
else:
self.slide_muzica.disabled =False
self.slide_muzica.value = 0
示例4: build
# 需要导入模块: from kivy.uix.slider import Slider [as 别名]
# 或者: from kivy.uix.slider.Slider import bind [as 别名]
def build(self):
# Set up the layout:
layout = GridLayout(cols=5, spacing=30, padding=30, row_default_height=150)
# Make the background gray:
with layout.canvas.before:
Color(.2,.2,.2,1)
self.rect = Rectangle(size=(800,600), pos=layout.pos)
# Instantiate the first UI object (the GPIO input indicator):
inputDisplay = InputButton(text="Input")
# Schedule the update of the state of the GPIO input button:
Clock.schedule_interval(inputDisplay.update, 1.0/10.0)
# Create the rest of the UI objects (and bind them to callbacks, if necessary):
outputControl = ToggleButton(text="LED")
outputControl.bind(on_press=press_callback)
beepButton = Button(text="BEEP!")
beepButton.bind(on_press=press_callback)
wimg = Image(source='logo.png')
speedSlider = Slider(orientation='vertical', min=1, max=30, value=speed)
speedSlider.bind(on_touch_down=update_speed, on_touch_move=update_speed)
# Add the UI elements to the layout:
layout.add_widget(wimg)
layout.add_widget(inputDisplay)
layout.add_widget(outputControl)
layout.add_widget(beepButton)
layout.add_widget(speedSlider)
# Start flashing the LED
Clock.schedule_once(flash, 1.0/speed)
return layout
示例5: __init__
# 需要导入模块: from kivy.uix.slider import Slider [as 别名]
# 或者: from kivy.uix.slider.Slider import bind [as 别名]
def __init__(self, childHeight, **kwargs):
super(ListView,self).__init__(**kwargs)
self.__childHeight = childHeight
scroll = ScrollViewFixed(bar_width=30,
bar_margin=-30,
bar_color=[0.8,.8,.8,.99],
do_scroll_y = True,
do_scroll_x = False,
pos_hint= {'x':0,'y':0},
size_hint = (None,None),
size = self.size)
box = BoxLayout(orientation='vertical',size_hint=(None,None),
size = self.size)
scroll.add_widget(box)
super(ListView, self).add_widget(scroll)
s = Slider(orientation='vertical', value_normalized = 0.5,
size_hint =(None,None), padding = 20,
size = (30, self.size[1]), pos_hint = {'x':1, 'y':0})
scroll.slider = s
def scrollMoves(slid,pos):
scroll.scroll_y = pos
s.bind(value_normalized=scrollMoves)
super(ListView, self).add_widget(s, 1)
self.scroll = scroll
self.box = box
示例6: build
# 需要导入模块: from kivy.uix.slider import Slider [as 别名]
# 或者: from kivy.uix.slider.Slider import bind [as 别名]
def build(self): #UIの構築等
self._cap = cv2.VideoCapture(0)
# ButtonやSlider等は基本size_hintでサイズ比率を指定(絶対値の時はNoneでsize=)
# 日本語フォントを使いたいときはfont_nameでフォントへのパス
kvButton1 = Button(text='ボタン', size_hint=(1.0, 0.1), font_name='/usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/ipag.ttf')
kvButton1.bind(on_press = self.buttonCallback) #bindでイベントごとにコールバック指定
# Imageに後で画像を描く
self.kvImage1 = Image(size_hint=(1.0, 0.7))
# Layoutを作ってadd_widgetで順次モノを置いていく(並びは置いた順)
kvLayout1 = BoxLayout(orientation='vertical')
kvLayout1.add_widget(self.kvImage1)
# ここだけ2columnでLabelとSliderを並べる
# Verticalの中に置くhorizontalなBoxLayout
kvLayout2 = BoxLayout(orientation='horizontal', size_hint=(1.0, 0.1))
self.kvSlider1Label = Label(text = 'Slider', size_hint=(0.3, 1.0), halign='center')
kvSlider1 = Slider(size_hint=(0.7, 1.0))
kvSlider1.bind(value=self.slideCallback)
kvLayout1.add_widget(kvLayout2)
kvLayout2.add_widget(self.kvSlider1Label)
kvLayout2.add_widget(kvSlider1)
# 1columnに戻る
kvLayout1.add_widget(kvButton1)
#カメラ待ち
while not self._cap.isOpened():
pass
# 更新スケジュールとコールバックの指定
Clock.schedule_interval(self.update, 1.0/30.0)
return kvLayout1
示例7: build
# 需要导入模块: from kivy.uix.slider import Slider [as 别名]
# 或者: from kivy.uix.slider.Slider import bind [as 别名]
def build(self):
root = BoxLayout(orientation='vertical')
viewer = KinectViewer()
root.add_widget(viewer)
toolbar = BoxLayout(size_hint=(1, None), height=50)
root.add_widget(toolbar)
slider = Slider(min=1., max=10., value=1.)
def update_depth_range(instance, value):
viewer.depth_range = value
slider.bind(value=update_depth_range)
toolbar.add_widget(slider)
button = Button(text='Use RGB shader')
def use_rgb(*l):
viewer.canvas.shader.fs = rgb_kinect
button.bind(on_press=use_rgb)
toolbar.add_widget(button)
button = Button(text='Use HSV shader')
def use_hsv(*l):
viewer.canvas.shader.fs = hsv_kinect
button.bind(on_press=use_hsv)
toolbar.add_widget(button)
return root
示例8: setup_gui
# 需要导入模块: from kivy.uix.slider import Slider [as 别名]
# 或者: from kivy.uix.slider.Slider import bind [as 别名]
def setup_gui(self):
self.ParentLayout = GridLayout(cols=3, row_force_default=True, row_default_height=200)
self.label = Label(text='connecting...\n')
# Additional code to exercise, so you can adapt related code on server for example
Matrix_Row_Slider = Slider(min=0, max=8, value=1)
Matrix_Row_Slider.bind(value=self.onMatrix_Row_Slidervalue) # handy to know what are the slider's position
Matrix_Col_Slider = Slider(min=0, max=8, value=1)
Matrix_Col_Slider = Slider(orientation='vertical')
self.ParentLayout.add_widget(Matrix_Row_Slider)
self.Matrix_Layout = GridLayout(cols=8)
# Let's add a spinner to be able to select some colors
self.Colorspinner = Spinner(text='Green', values=('NA','Green','Red','Orange', 'Cls'), size_hint=(None, None),size=(90, 44), pos_hint={'center_x': .5, 'center_y': .5})
# We define the main buttons matrix here
for i in range(64):
btn = Button(text=str(i), size_hint_x=None,size_hint_y=None, width=20, height=20 )
btn.bind(on_press=self.callback)
self.Matrix_Layout.add_widget(btn)
self.ParentLayout.add_widget(self.Matrix_Layout)
self.ParentLayout.add_widget(self.label)
self.ParentLayout.add_widget(self.Colorspinner)
self.ParentLayout.add_widget(Matrix_Col_Slider)
return self.ParentLayout
示例9: build
# 需要导入模块: from kivy.uix.slider import Slider [as 别名]
# 或者: from kivy.uix.slider.Slider import bind [as 别名]
def build(self):
self.root = BoxLayout(pos_hint={'center_x':.5, 'center_y':.5}, orientation='vertical')
self.svg = SvgWidget(size_hint_y=0.9)
self.root.add_widget(self.svg)
s = Slider(min=0, max=100, value=0, size_hint_y=0.1)
self.root.add_widget(s)
s.bind(value=self.on_value)
s.value=50
示例10: go
# 需要导入模块: from kivy.uix.slider import Slider [as 别名]
# 或者: from kivy.uix.slider.Slider import bind [as 别名]
def go(self,screen):
if screen=="about":
cnt=BoxLayout(padding=0,spacing=0)
lbl=Label(text=" [size=20]pyPuzzle Game[/size]\n\nSimple fun memory game\n\n"
"Match simple jelly images\n\nEnter your scores.\n\n"
"www.yahyakesenek.com @2016",markup=True)
cnt.add_widget(lbl)
modal=ModalView(size_hint=(0.7,0.5),background_color=get_color_from_hex("#ff7373"))
modal.add_widget(cnt)
modal.open()
modal.x=self.root.x-modal.width-10
anim=Animation(center_x=self.root.center_x,center_y=self.root.center_y,d=2,t="out_expo")
anim.start(modal)
return
if screen=="settings":
cnt=BoxLayout()
lbl=Label(text="Set Sound Volume :")
sld=Slider(max=100,min=0,value=25)
sld.bind(value=self.value_change)
cnt.add_widget(lbl);cnt.add_widget(sld)
modal=ModalView(size_hint=(0.8,0.2),background_color=get_color_from_hex("#ff7373"))
modal.add_widget(cnt)
modal.open()
modal.x=self.root.x+modal.width+10
anim=Animation(center_x=self.root.center_x,center_y=self.root.center_y,d=2,t="out_expo")
anim.start(modal)
self.sld=sld
return
if screen=="exit":
cnt=BoxLayout(size_hint=(0.8,0.5),padding=4,spacing=5)
lbl=Label(text="[size=35][color=#ae5a41]Quit?[/color][/size]",markup=True)
btnyes=Button(text="Yes")
btnno=Button(text="No")
modal=ModalView(size_hint=(0.8,0.2))
def quit(inst):
exit()
def cancel(inst):
if modal:
modal.dismiss()
if self.root.current=="game_screen":
self.root.current_screen.newGame()
btnyes.bind(on_release=quit)
btnno.bind(on_release=cancel)
cnt.add_widget(lbl)
cnt.add_widget(btnyes)
cnt.add_widget(btnno)
modal.add_widget(cnt)
modal.open()
return
if screen=="end_screen":
self.level=1
self.root.current=screen
if self.root.current=="main_screen":
if self.snd.state=="stop":
self.snd.play()
else:
self.snd.stop()
示例11: build
# 需要导入模块: from kivy.uix.slider import Slider [as 别名]
# 或者: from kivy.uix.slider.Slider import bind [as 别名]
def build(self):
root = Widget()
puzzle = Puzzle(resolution=(640, 480), play=True)
slider = Slider(min=100, max=200, step=10, size=(800, 50))
slider.bind(value=partial(self.on_value, puzzle))
root.add_widget(puzzle)
root.add_widget(slider)
return root
示例12: _get_form
# 需要导入模块: from kivy.uix.slider import Slider [as 别名]
# 或者: from kivy.uix.slider.Slider import bind [as 别名]
def _get_form(self):
slider = Slider(id='value', min=self.min, max=self.max,
value=self.value, orientation=self.orientation)
slider.bind(value=self.setter('value'))
bind = self.bind
bind(min=slider.setter('min'))
bind(max=slider.setter('max'))
bind(value=slider.setter('value'))
bind(orientation=slider.setter('orientation'))
return slider
示例13: build
# 需要导入模块: from kivy.uix.slider import Slider [as 别名]
# 或者: from kivy.uix.slider.Slider import bind [as 别名]
def build(self):
from kivy.uix.gridlayout import GridLayout
from kivy.uix.slider import Slider
import random
def test(*args):
lang_pizza.legend_value_rayon = slider_ray.value
fruit_pizza.legend_value_rayon = slider_ray.value
def rand(*args):
lang = ["Français", "Belge", "Anglais", "Allemand", "Italien"]
value = [25, 10, 15, 30, 20]
color = ['a9a9a9', '808080', '696969', '778899', '708090']
random.shuffle(lang)
random.shuffle(value)
random.shuffle(color)
lang_pizza.serie = zip(lang, value, color)
layout = GridLayout(cols=2, padding=50)
lang_pizza = Pizza(serie=[
["Français", 5, 'a9a9a9'],
["Belge", 25, '808080'],
["Anglais", 20, '696969'],
["Allemand", 30, '778899'],
["Italien", 20, '708090']],
chart_size=256,
legend_color='ffffcc',
legend_value_rayon=100,
legend_title_rayon=170,
chart_border=2)
fruit_pizza = Pizza(serie=[
["Pomme", 20, '6495ed'],
["Poire", 20, '7b68ee'],
["Abricot", 20, '4169e1'],
["Prune", 20, '0000ff'],
["Ananas", 20, '00008b']],
chart_size=256,
legend_color='ffffcc',
legend_value_rayon=100,
legend_title_rayon=170,
chart_border=2)
slider_v = Slider(min=0, max=300, value=50)
slider_v.bind(value=rand)
slider_ray = Slider(min=0, max=250, value=100)
slider_ray.bind(value=test)
layout.add_widget(lang_pizza)
layout.add_widget(fruit_pizza)
layout.add_widget(slider_v)
layout.add_widget(slider_ray)
return layout
示例14: build
# 需要导入模块: from kivy.uix.slider import Slider [as 别名]
# 或者: from kivy.uix.slider.Slider import bind [as 别名]
def build(self):
root = Widget()
print(root.height,root.width)
puzzle = Camera(size=(480, 320), resolution=(480, 320), play=True, allow_stretch=True)
print("The camera is a {}".format(puzzle))
slider = Slider(min=100, max=400, step=10, size=(800, 50))
slider.value=100
slider.bind(value=partial(self.on_value, puzzle))
root.add_widget(puzzle)
root.add_widget(slider)
return root
示例15: addSettingsView
# 需要导入模块: from kivy.uix.slider import Slider [as 别名]
# 或者: from kivy.uix.slider.Slider import bind [as 别名]
def addSettingsView(self):
"""
creates settings view and adds it to SettingsPanel layout
:return:
"""
layout = FloatLayout(size_hint = (1.0, 0.6))
# item position Y coordinates
firstRowY = 0.85
secondRowY = 0.750
thirdRowY = 0.70
fourthRowY = 0.60
self.addLabel(layout, "Sort By:", 0.5, 0.90)
self.addLabel(layout, "NAME", 0.15, firstRowY)
self.addLabel(layout, "OR", 0.5, firstRowY)
self.addLabel(layout, "PRICE", 0.85, firstRowY)
self.addLabel(layout, "IN", 0.5, secondRowY )
self.addLabel(layout, "DESCEND", 0.85, thirdRowY )
self.addLabel(layout, "OR", 0.5, thirdRowY)
self.addLabel(layout, "ASCEND", 0.15, thirdRowY)
self.addLabel(layout, "USING", 0.5, fourthRowY)
self.addLabel(layout, "TIME: ", 0.15, 0.2)
self.timeLabel = self.addLabel(layout, "0 seconds", 0.43, 0.2)
self.checkbox = CheckBox(pos_hint = {"center_x" : 0.370, "center_y" : firstRowY}, size_hint = (0.1, 0.1))
self.checkbox.bind(active = self.nameCheckbox)
layout.add_widget(self.checkbox)
self.checkbox = CheckBox(pos_hint = {"center_x" : 1-0.370, "center_y" : firstRowY}, size_hint = (0.1, 0.1))
self.checkbox.bind(active = self.priceCheckbox)
layout.add_widget(self.checkbox)
self.checkbox = CheckBox(pos_hint = {"center_x" : 0.370, "center_y" : thirdRowY}, size_hint = (0.1, 0.1))
self.checkbox.bind(active = self.ascendingCheckbox)
layout.add_widget(self.checkbox)
self.checkbox = CheckBox(pos_hint = {"center_x" : 1-0.370, "center_y" : thirdRowY}, size_hint = (0.1, 0.1))
self.checkbox.bind(active = self.descendingCheckbox)
layout.add_widget(self.checkbox)
spinner = Spinner(
text='Sort algorithm...',
values=('Insertion sort', 'Bubble sort'),
size_hint=(1.0, 0.1),
pos_hint={'center_x': .5, 'center_y': .5})
spinner.bind(text=self.algorithmSelection)
layout.add_widget(spinner)
button = Button(on_press=self.startButton, text="START", pos_hint={"center_x":0.5, "bottom":0.0}, size_hint=(1.0,0.1))
layout.add_widget(button)
slider = Slider(min= 0, max= 60, step=1, value=0, pos_hint = {"center_x" : 0.5, "center_y" : 0.3}, size_hint=(1.0,0.2))
slider.bind(value=self.slider)
layout.add_widget(slider)
self.addToPanel(layout)