Created
December 14, 2015 20:15
-
-
Save clayote/a0c9d38016d8cb783e50 to your computer and use it in GitHub Desktop.
I want this button to open up that ListView but it won't.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from kivy.app import App | |
| from kivy.adapters.simplelistadapter import SimpleListAdapter | |
| from kivy.lang import Builder | |
| from kivy.properties import ObjectProperty | |
| from kivy.uix.button import Button | |
| from kivy.uix.dropdown import DropDown | |
| class ListDropDown(DropDown): | |
| adapter = ObjectProperty() | |
| class ListDropDownButton(Button): | |
| mainbut = ObjectProperty() | |
| def on_release(self, *args): | |
| self.mainbut.text = self.text | |
| class DropListTestApp(App): | |
| def build(self): | |
| b = Button( | |
| text='Press me', | |
| size_hint_y=None, | |
| pos_hint={'top': 1}, | |
| height=100 | |
| ) | |
| a = SimpleListAdapter( | |
| data=['spam', 'eggs', 'ham'], | |
| cls=ListDropDownButton, | |
| args_converter=lambda i, v: { | |
| 'text': v, | |
| 'mainbut': b | |
| } | |
| ) | |
| ldd = ListDropDown(adapter=a) | |
| b.bind(on_release=ldd.open) | |
| return b | |
| Builder.load_string(""" | |
| <ListDropDown>: | |
| ListView: | |
| adapter: root.adapter | |
| """) | |
| if __name__ == '__main__': | |
| DropListTestApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment