from kivy.properties import OptionProperty class MyWidget(Widget): state = OptionProperty('off', options=['on', 'off'])
from kivy.base import runTouchApp from kivy.properties import OptionProperty from kivy.uix.dropdown import DropDown from kivy.uix.button import Button class MyWidget(Widget): options = ['Option 1', 'Option 2', 'Option 3'] selected = OptionProperty('', options=options) def build_dropdown(self): dropdown = DropDown() for option in options: button = Button(text=option) button.bind( on_release=lambda btn: setattr(self, 'selected', btn.text)) dropdown.add_widget(button) select_button = Button(text='Select') select_button.bind(on_release=dropdown.open) dropdown.bind(on_select=lambda instance, x: setattr(self, 'selected', x)) self.add_widget(select_button) runTouchApp(MyWidget())In this example, an OptionProperty is used to keep track of the selected option. The options list is used to generate buttons in a dropdown menu. The selected property is updated when the user selects an option. Package library: kivy.properties