mirror of https://github.com/kivy/kivy.git
Add doubling button to examples/canvas/canvas_stress.py
This commit is contained in:
parent
650e539631
commit
ad8ac20782
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue