diff --git a/examples/guide/firstwidget/6_button.py b/examples/guide/firstwidget/6_button.py index 667aed5e7..428a6bb00 100644 --- a/examples/guide/firstwidget/6_button.py +++ b/examples/guide/firstwidget/6_button.py @@ -23,17 +23,16 @@ class MyPaintApp(App): def build(self): parent = Widget() - painter = MyPaintWidget() + self.painter = MyPaintWidget() clearbtn = Button(text='Clear') - parent.add_widget(painter) + clearbtn.bind(on_release=self.clear_canvas) + parent.add_widget(self.painter) parent.add_widget(clearbtn) - - def clear_canvas(obj): - painter.canvas.clear() - clearbtn.bind(on_release=clear_canvas) - return parent + def clear_canvas(self, obj): + self.painter.canvas.clear() + if __name__ == '__main__': MyPaintApp().run()