F
F
Forque2016-07-12 15:46:00
Python
Forque, 2016-07-12 15:46:00

How to make DropDown in Kivy in this example, when pressed, not only opened but also closed on the same button?

<CustomDropDown>:

    Button:
        id: btn
        text: 'Press'
        on_release: dropdown.open(self)
        size_hint_y: None
        height: '48dp'

    DropDown:

        id: dropdown
        on_parent: self.dismiss()
        on_select: btn.text = '{}'.format(args[1])

        Button:
            text: 'First Item'
            size_hint_y: None
            height: '48dp'
            on_release: dropdown.select('First Item')

        Label:
            text: 'Second Item'
            size_hint_y: None
            height: '48dp'

        Button:
            text: 'Third Item'
            size_hint_y: None
            height: '48dp'
            on_release: dropdown.select('Third Item')

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question