'DropDown Button in kivy closes immediately
I'm trying to implement a dropdown button in kivy but it closes immediately , I have seen other examples but i can't manage to understand them , any suggestions ?
from kivy.app import App
from kivy.lang import Builder
kv = '''
BoxLayout:
orientation: 'vertical'
BoxLayout:
size_hint_y: None
height: '50sp'
Button:
id: button
text: 'Open dropdown'
Widget:
DropDown:
id: dropdown
on_parent: self.dismiss()
Button:
size_hint_y: None
text: 'item 1'
Button:
size_hint_y: None
text: 'item 2'
Button:
size_hint_y: None
text: 'item 3'
'''
class MyApp(App):
def build(self):
self.root = Builder.load_string(kv)
self.root.ids.button.bind(on_release=self.root.ids.dropdown.open)
return self.root
MyApp().run()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
