Below I have provided an example for creating a drop down list in Kivy using ScreenManager. Just as a note, this will work in all layouts, but I find that GridLayout to be the easiest to control. You can copy and paste this into your code.
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
Builder.load_file("try_out_app.kv")
class ExampleScreen(Screen):
pass
class RootWidget(ScreenManager):
pass
class Demo(App):
def build(self):
return RootWidget()
if __name__ == "__main__":
Demo().run()
try_out_app.kv
<ExampleScreen>:
name: "example_screen" GridLayout:
cols: 1
padding: 10, 10
size_hint: 0.5, 0.5 Button:
id: btn
text: "Press me !!"
size_hint: None, None
on_parent: drop_content.dismiss()
on_release: drop_content.open(self) DropDown:
id: drop_content
on_select: btn.text = f'{args[1]}' # see note below Button:
id: btn1
text: 'First Item'
size_hint: None, None
height: 35
on_release: drop_content.select('First Item') Button:
id: btn3
text: 'Second Item'
size_hint: None, None
height: 35
on_release: drop_content.select('Third Item')
<RootWidget>:
ExampleScreen
args[1] refers to the second element in elements of the DropDown list, in this case each arg is a Button. Therefore args[1] would be the text for each button under the DropDown list.