Skip to content
Browse files

combobox: added example in module docstringe, pep8 fixes

  • Loading branch information...
1 parent 1d09bb0 commit a87b69af0b28c6ddffee7976255349790cff6fe3 @tshirtman tshirtman committed Mar 19, 2012
Showing with 17 additions and 11 deletions.
  1. +4 −7 examples/widgets/combobox.py
  2. +13 −4 kivy/uix/combobox.py
View
11 examples/widgets/combobox.py
@@ -1,9 +1,7 @@
from kivy.app import App
from kivy.uix.combobox import ComboBox
-from kivy.uix.label import Label
from kivy.uix.floatlayout import FloatLayout
-
class ComboBoxTest(App):
def build(self):
@@ -13,15 +11,14 @@ def build(self):
pos_hint={'center_x': .5, 'center_y': .7},
size_hint=(None, None),
size=(200, 40),
- selected_color=(1, .2, .2, 1)
- )
+ selected_color=(1, .2, .2, 1))
+
c.bind(text=self.text_changed,
current_index=self.index_changed,
- highlight_index=self.on_highlight
- )
+ highlight_index=self.on_highlight)
f.add_widget(c)
- return f
+ return f
def text_changed(self, instance, value):
print 'Text changed: %s' % value
View
17 kivy/uix/combobox.py
@@ -7,11 +7,18 @@
A button that allows selecting a value from several options
-
.. warning::
This is experimental and subject to change as long as this warning notice is
present.
+
+Example:
+ c = ComboBox(
+ values=['a', 'b', 'c', 'd'],
+ pos_hint={'center_x': .5, 'center_y': .7},
+ size_hint=(None, None),
+ size=(200, 40),
+ selected_color=(1, .2, .2, 1))
'''
from kivy.properties import ListProperty, ObjectProperty, NumericProperty
@@ -30,8 +37,8 @@ class ComboBox(Button):
select_class = ObjectProperty(Label)
'''The class used to represent the options when displayed. The value will be
- passed the `text` and the `color` properties. It can be used to customize the apparence of the
- list.
+ passed the `text` and the `color` properties. It can be used to customize
+ the apparence of the list.
:data:`select_class` is an :class:`~kivy.properties.ObjectProperty`, default
to `~kivy.uix.label.Label`.
@@ -40,7 +47,8 @@ class ComboBox(Button):
selected_color = ListProperty([1, 1, 1, 1])
'''Text color when overed by the touch, in the format (r, g, b, a)
- :data:`selected_color` is a :class:`~kivy.properties.ListProperty`, default to [1, 1, 1, 1].
+ :data:`selected_color` is a :class:`~kivy.properties.ListProperty`, default
+ to [1, 1, 1, 1].
'''
current_index = NumericProperty(0)
@@ -99,3 +107,4 @@ def on_touch_up(self, touch, *args):
self.remove_widget(touch.ud['combobox_grid'])
return True
self.remove_widget(touch.ud['combobox_grid'])
+

0 comments on commit a87b69a

Please sign in to comment.
Something went wrong with that request. Please try again.