Merge pull request #613 from esbullington/spinner_mod

Modified spinner to close on (re-)click
This commit is contained in:
Mathieu Virbel 2012-08-07 08:42:47 -07:00
commit 355f49c30e
2 changed files with 15 additions and 3 deletions

View File

@ -139,6 +139,14 @@ class DropDown(ScrollView):
default to True.
'''
is_open = BooleanProperty(False)
'''By default, the dropdown is not open. Set to True to expand the dropdown
by default.
:data: `is_open` is a :class: `~kivy.properties.BooleanProperty`,
default to False.
'''
attach_to = ObjectProperty(allownone=True)
'''(internal) Property that will be set to the widget on which the drop down
list is attached to.

View File

@ -116,7 +116,6 @@ class Spinner(Button):
def _update_dropdown(self, *largs):
dp = self._dropdown
cls = self.option_cls
dp.clear_widgets()
for value in self.values:
item = cls(text=value)
@ -124,8 +123,13 @@ class Spinner(Button):
dp.add_widget(item)
def _open_dropdown(self, *largs):
self._dropdown.open(self)
if not self._dropdown.is_open:
self._dropdown.open(self)
self._dropdown.is_open = True
else:
self._dropdown.dismiss()
self._dropdown.is_open = False
def _on_dropdown_select(self, instance, data, *largs):
self.text = data
self._dropdown.is_open = False