Kivy Spinner:是从Spinner中选择一个值时触发的任何事件 [英] Kivy Spinner: is any event triggered when a value is selected from the Spinner
本文介绍了Kivy Spinner:是从Spinner中选择一个值时触发的任何事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在窗口小部件中引入了Spinner
,每当我从中选择一个不同的值时,我都想执行一些操作.
I introduce a Spinner
in my widget, and I want to perform some action every time I chose a different value from it.
有可能吗?
我只能似乎得到事件
I only seem to get events on_press
and on_release
, but they are not triggered when a choice for a different value is made :-(
最诚挚的问候,
Bojan
推荐答案
由于微调器每次都会更改attr:values值时更改其text属性,所以我会这样:
Beacuse the spinner updates its text property every time attr:values are changes,
I would do someting like this:
Spinner:
text: '<select>'
values: ['White', 'Yellow', 'Red', 'Green']
on_text: root.on_spinner_select(self.text)
在python代码中:
In python code:
class RootWidget(BoxLayout):
def on_spinner_select(self, text):
print (text)
这篇关于Kivy Spinner:是从Spinner中选择一个值时触发的任何事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文