From ad8ac2078287c391cdb93186566b876b45803a5b Mon Sep 17 00:00:00 2001 From: Charles Merriam Date: Sat, 31 Jan 2015 18:03:07 -0800 Subject: [PATCH] Add doubling button to examples/canvas/canvas_stress.py --- examples/canvas/canvas_stress.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/canvas/canvas_stress.py b/examples/canvas/canvas_stress.py index c86f439be..ff3fd84b8 100644 --- a/examples/canvas/canvas_stress.py +++ b/examples/canvas/canvas_stress.py @@ -25,6 +25,10 @@ class StressCanvasApp(App): Rectangle(pos=(r() * wid.width + wid.x, r() * wid.height + wid.y), size=(20, 20)) + def double_rects(self, label, wid, *largs): + count = int(label.text) + self.add_rects(label, wid, count, *largs) + def reset_rects(self, label, wid, *largs): label.text = '0' wid.canvas.clear() @@ -40,12 +44,16 @@ class StressCanvasApp(App): btn_add500 = Button(text='+ 500 rects', on_press=partial(self.add_rects, label, wid, 500)) + btn_double = Button(text='x 2', + on_press=partial(self.double_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) layout.add_widget(btn_add500) + layout.add_widget(btn_double) layout.add_widget(btn_reset) layout.add_widget(label)