Display kivy slider value as it changes [closed]

瘦欲@ 提交于 2019-12-08 17:01:00

问题


I was wondering whether it was possible to displays kivy spinner values as a moving label, so that the user knows exactly what the current value of the slider is.

Thanks


回答1:


you just bind a listener to the value change event

some_label = Label(...)
my_slider = Slider(...)
def OnSliderValueChange(instance,value):
    some_label.text = str(value)

my_slider.bind(value=OnSliderValueChange)

as inclement points out in the .kv file you could do something like

<PongGame>:
    ...
    canvas:
        Rectangle:
            ...
    Label:
        ...
        text: str(slider_id.value)
     Slider:
        ...
        id: slider_id


来源:https://stackoverflow.com/questions/22820553/display-kivy-slider-value-as-it-changes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!