-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsuma.py
41 lines (30 loc) · 927 Bytes
/
suma.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
Loading multiple instances of a widget over a period of time to prevent lag
"""
from kivy.app import App
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.uix.button import Button
from kivy.animation import Animation
KV = '''
GridLayout:
id:container
cols:5
rows:20
'''
class MessengerApp(App):
counter = 0
def build(self):
self.kv = Builder.load_string(KV)
return self.kv
def on_start(self):
Clock.schedule_interval(self.btn_create,0.3)
def btn_create(self,time):
if self.counter<50:
btn = Button(text = str(self.counter))
btn.opacity = 0 # Set the opacity of the button to 0
self.kv.add_widget(btn) # Add the button
Animation(opacity = 1, duration = .25).start(btn) # Duration is < than clock duration
self.counter +=1
if __name__ == '__main__':
MessengerApp().run()