Kivy Spinner - Default text in Python

214 views
Skip to first unread message

Northwarks

unread,
Dec 31, 2016, 4:08:01 PM12/31/16
to Kivy users support
Hi - I'm using the Spinner to select screens, I have a Spinner on each screen. When I select a screen it selects it no problem but the Spinner text remains the same so to capture on_text: it needs to be different. How can I use python to reset the Spinner to default text?


<FirstScreen>:

    name: 'first'

    the_time: _id_lbl_time

    menu_txt: menu_spinner


    BoxLayout:

        orientation: 'vertical'


        Spinner:

            text: '-'

            id: menu_spinner

            font_size: 20

            size: 800, 30

            size_hint: None, None

            values: ('first', 'second')

            on_text:

                root.show_selected_value(menu_spinner.text)

        Label

            id: _id_lbl_time

            text: 'Clock'

            font_size: 30




Towas

unread,
Jan 24, 2018, 10:28:39 AM1/24/18
to Kivy users support
My solution was edit the text content of the spinner, in my python file. 

for example:

First I put an id to the spinner, and in the on_text part I included the spinner id value

Spinner:

            id: spinner

            text: '-'

            id: menu_spinner

            font_size: 20

            size: 800, 30

            size_hint: None, None

            values: ('first''second')

            on_text:

                root.show_selected_value(spinner, menu_spinner.text)



Then in my python file I change the text value of the spinner, and then we go to the screen that we want. For example,

def show_selected_value(self, spinner,...)

            if spinner.text == "one of the possibles values":

                        spinner.text = "" # or the value that you want

                        self.manager.transition = NoTransition()

                        self.manager.current = "your screen"

                        self.manager.get_screen("your screen")

Reply all
Reply to author
Forward
0 new messages