Merge pull request #785 from GendoIkari/master

Again on event binding
This commit is contained in:
Mathieu Virbel 2012-11-07 13:25:57 -08:00
commit 2474002228
5 changed files with 13 additions and 15 deletions

View File

@ -28,8 +28,7 @@ class TestApp(App):
def build(self):
# create a button, and attach animate() method as a on_press handler
button = Button(size_hint=(None, None), text='plop')
button.bind(on_press=self.animate)
button = Button(size_hint=(None, None), text='plop', on_press=self.animate)
return button
if __name__ == '__main__':

View File

@ -34,14 +34,14 @@ class StressCanvasApp(App):
label = Label(text='0')
btn_add100 = Button(text='+ 100 rects')
btn_add100.bind(on_press=partial(self.add_rects, label, wid, 100))
btn_add100 = Button(text='+ 100 rects',
on_press=partial(self.add_rects, label, wid, 100))
btn_add500 = Button(text='+ 500 rects')
btn_add500.bind(on_press=partial(self.add_rects, label, wid, 500))
btn_add500 = Button(text='+ 500 rects',
on_press=partial(self.add_rects, label, wid, 500))
btn_reset = Button(text='Reset')
btn_reset.bind(on_press=partial(self.reset_rects, label, wid))
btn_reset = Button(text='Reset',
on_press=partial(self.reset_rects, label, wid))
layout = BoxLayout(size_hint=(1, None), height=50)
layout.add_widget(btn_add100)

View File

@ -259,8 +259,8 @@ class ShowcaseApp(App):
auto_dismiss=False)
btnclose.bind(on_release=popup.dismiss)
button = Button(text='Open popup', size_hint=(None, None),
size=('150sp', '70dp'))
button.bind(on_release=popup.open)
size=('150sp', '70dp'),
on_release=popup.open)
popup.open()
col = AnchorLayout()
col.add_widget(button)

View File

@ -22,8 +22,7 @@ class CustomPopup(Popup):
class TestApp(App):
def build(self):
b = Button()
b.bind(on_press=self.show_popup)
b = Button(on_press=self.show_popup)
return b
def show_popup(self, b):

View File

@ -154,9 +154,9 @@ class Widget(EventDispatcher):
# Builder.idmap.pop('root')
# Bind all the events
for argument, value in kwargs.items():
if argument.startswith('on_'):
self.bind(**{argument: value})
for argument in kwargs:
if argument[:3] == 'on_':
self.bind(**{argument: kwargs[argument]})
#
# Collision