forked from namkazt/Kivy-Datagrid-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kivy-fade-in-example.py
59 lines (44 loc) · 1.6 KB
/
kivy-fade-in-example.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python2
# From: http://codegist.net/search/kivy-datagrid/2
'''
Under WTFPL - http://www.wtfpl.net
'''
import kivy
kivy.require('1.0.7')
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.animation import Animation
from kivy.core import window
SIZE = 30
FORMAT = (10, 16)
window.Window.size = [SIZE * i for i in FORMAT]
window.Window.clearcolor = [0.2, 0.2, 0.2, 1]
class lightButton(Button):
def __init__(self, *args, **kws):
kws.update(background_color=[1, 1, 1, 1])
Button.__init__(self, *args, **kws)
self.border = [16, 16, 30, 16]
class lightLabel(Label):
def __init__(self, *args, **kws):
Label.__init__(self, *args, **kws)
class TestApp(App):
def compl(self, *args, **kws):
print "complete:animation"
def animate_label(self, instance):
self.main_label.color = [1, 1, 1, 0]
anim = Animation(color=[1, 1, 1, 0.7])
anim.bind(on_complete=self.compl)
anim.start(self.main_label)
def build(self):
self.main_grid = GridLayout(rows=2, cols=1, padding=50)
print("Needs ./Aliquam.ttf")
self.main_label = lightLabel(text='Text example test', color=[1, 1, 1, 0.0],
font_name='./Aliquam.ttf', font_size='30px')
self.main_button = lightButton(text='ok', on_press=self.animate_label)
self.main_grid.add_widget(self.main_label)
self.main_grid.add_widget(self.main_button)
return self.main_grid
if __name__ == '__main__':
TestApp().run()