diff --git a/kivy/uix/dropdown.py b/kivy/uix/dropdown.py index 94ded676b..acc9f19c4 100644 --- a/kivy/uix/dropdown.py +++ b/kivy/uix/dropdown.py @@ -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. diff --git a/kivy/uix/spinner.py b/kivy/uix/spinner.py index 2ed45a64f..45939c7d4 100644 --- a/kivy/uix/spinner.py +++ b/kivy/uix/spinner.py @@ -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