在更改时显示kivy滑块值 [英] Display kivy slider value as it changes

查看:104
本文介绍了在更改时显示kivy滑块值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以将kivy微调器值显示为移动标签,以便用户确切知道滑块的当前值是什么.

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.

谢谢

推荐答案

您只需将侦听器绑定到值更改事件

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)

在.kv文件中,正如所指出的那样,您可以执行类似的操作

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

这篇关于在更改时显示kivy滑块值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆