Version

Quick search

Table Of Contents

Spinner

New in version 1.4.0.

_images/spinner.jpg

Spinner is a widget that provides a quick way to select one value from a set. In the default state, a spinner shows its currently selected value. Touching the spinner displays a dropdown menu with all the other available values from which the user can select a new one.

Example:

from kivy.base import runTouchApp
from kivy.uix.spinner import Spinner

spinner = Spinner(
    # default value shown
    text='Home',
    # available values
    values=('Home', 'Work', 'Other', 'Custom'),
    # just for positioning in our example
    size_hint=(None, None),
    size=(100, 44),
    pos_hint={'center_x': .5, 'center_y': .5})

def show_selected_value(spinner, text):
    print('The spinner', spinner, 'has text', text)

spinner.bind(text=show_selected_value)

runTouchApp(spinner)

Kv Example:

FloatLayout:
    Spinner:
        size_hint: None, None
        size: 100, 44
        pos_hint: {'center': (.5, .5)}
        text: 'Home'
        values: 'Home', 'Work', 'Other', 'Custom'
        on_text:
            print("The spinner {} has text {}".format(self, self.text))
class kivy.uix.spinner.Spinner(**kwargs)

Bases: kivy.uix.button.Button

Spinner class, see module documentation for more information.

class kivy.uix.spinner.SpinnerOption(**kwargs)

Bases: kivy.uix.button.Button

Special button used in the Spinner dropdown list. By default, this is just a Button with a size_hint_y of None and a height of 48dp.