Using OptionProperties and Spinners

53 views
Skip to first unread message

Yoel Koenka

unread,
May 22, 2015, 11:43:18 AM5/22/15
to kivy-...@googlegroups.com
In my app I'm using a Spinner.
It seemed to me like a good idea to back it up from the Python side with an OptionProperty, and use it to initialize the Spinner:

<DigitalVariable>:
    Spinner:
        text: root.value
        values: root.value.options

class DigitalVariable(Variable):
   
'''A digital variable
    '''


    value
= OptionProperty('???', options=['???'])
   
'''The current value with its possible options
    '''



root.value is an OptionProperty (created in the python code), so I thought I could get its options by using root.value.options. But that doesn't work.
Is there another way to access the options?

Is there a better way of using Spinners that I'm missing?

Alexander Taylor

unread,
May 22, 2015, 12:12:23 PM5/22/15
to kivy-...@googlegroups.com
You could just use a ListProperty.

Yoel Koenka

unread,
May 22, 2015, 2:55:42 PM5/22/15
to kivy-...@googlegroups.com
Thanks for the advice, I'll do that.

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/mVjaEdF86W0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rafał Kaczor

unread,
Aug 20, 2016, 8:25:09 PM8/20/16
to Kivy users support
If someone is looking for the answer, here's how to use Spinner and OptionProperty. We need to get the property object first, and then we can easily bind Spinner's values with OptionProperty options.

Spinner:
    values: widget,property('option_property_name').options

The widget reference is of course widget that has the OptionProperty we want to use.

Cheers!
Reply all
Reply to author
Forward
0 new messages