在更改时显示 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
相关文章