forked from dimi3o/MobAdaptUi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
81 lines (68 loc) · 2.14 KB
/
test.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from kivy.app import App
from kivy.metrics import dp
from kivy.uix.behaviors import TouchRippleBehavior
from kivy.uix.button import Button
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
KV = """
<RectangleFlatButton>:
ripple_color: 0, 0, 0, .2
background_color: 0, 0, 0, 0
color: root.primary_color
canvas.before:
Color:
rgba: root.primary_color
Line:
width: 1
rectangle: (self.x, self.y, self.width, self.height)
Screen:
canvas:
Color:
rgba: 0.9764705882352941, 0.9764705882352941, 0.9764705882352941, 1
Rectangle:
pos: self.pos
size: self.size
"""
class RectangleFlatButton(TouchRippleBehavior, Button):
primary_color = [
0.12941176470588237,
0.5882352941176471,
0.9529411764705882,
1
]
def on_touch_down(self, touch):
collide_point = self.collide_point(touch.x, touch.y)
if collide_point:
touch.grab(self)
self.ripple_show(touch)
return True
return False
def on_touch_up(self, touch):
if touch.grab_current is self:
touch.ungrab(self)
self.ripple_fade()
return True
return False
def get_hor_boxlayout(orientation='horizontal', padding=10, spacing=10):
return BoxLayout(orientation=orientation, padding=padding, spacing=spacing)
class MainApp(App):
def build(self):
screen = Builder.load_string(KV)
hor = get_hor_boxlayout()
hor.add_widget(RectangleFlatButton(
text="Hello, World",
pos_hint={"center_x": 0.5, "center_y": 0.5},
size_hint=(None, None),
size=(dp(110), dp(35)),
ripple_color=(0.8, 0.8, 0.8, 0.5),
))
hor.add_widget(RectangleFlatButton(
text="Hello, World",
pos_hint={"center_x": 0.5, "center_y": 0.5},
size_hint=(None, None),
size=(dp(110), dp(35)),
ripple_color=(0.8, 0.8, 0.8, 0.5),
))
screen.add_widget(hor)
return screen
MainApp().run()