arkivy 1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
arkivy-1.0/PKG-INFO ADDED
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.1
2
+ Name: arkivy
3
+ Version: 1.0
4
+ Summary: Help library with kivy in Arabic language formatting
5
+ Author: ALI KAZM
6
+
7
+
8
+
9
+ install library
10
+
11
+ ``pip instal arkivy``
12
+
13
+
@@ -0,0 +1,3 @@
1
+ from .button import ArButton
2
+ from .label import ArLabel
3
+ from .textinput import ArTextInput,ArTextInputBase
@@ -0,0 +1,23 @@
1
+
2
+ from .utils import ar
3
+ from .label import ArLabel
4
+ from kivy.uix.button import Button
5
+ from .ripple import RectangularRippleBehavior
6
+
7
+ __all__=('ArButton',)
8
+
9
+
10
+ class ArButton(ArLabel,RectangularRippleBehavior,Button):
11
+ pass
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
@@ -0,0 +1,23 @@
1
+ from kivy.properties import StringProperty
2
+ from kivy.uix.label import Label
3
+ from .utils import ar
4
+
5
+ __all__=('ArLabel',)
6
+
7
+ class ArLabel(Label):
8
+ text=StringProperty()
9
+ def __init__(self,*args,**kwargs):
10
+ super().__init__(*args,**kwargs)
11
+ #self.font_name=
12
+ self._label.text=ar(self.text)
13
+ def _trigger_texture_update(self, name=None, source=None, value=None):
14
+ if source:
15
+ if name == 'text':
16
+ self._label.text = ar(value)
17
+ self._trigger_texture()
18
+ else:
19
+ return super()._trigger_texture_update(name,source,value)
20
+
21
+
22
+
23
+
@@ -0,0 +1,285 @@
1
+
2
+
3
+ __all__ = (
4
+ "CommonRipple",
5
+ "RectangularRippleBehavior",
6
+ "CircularRippleBehavior",
7
+ )
8
+
9
+ from typing import NoReturn
10
+
11
+ from kivy.animation import Animation
12
+ from kivy.graphics import (
13
+ Color,
14
+ Ellipse,
15
+ StencilPop,
16
+ StencilPush,
17
+ StencilUnUse,
18
+ StencilUse,
19
+ )
20
+ from kivy.graphics.vertex_instructions import RoundedRectangle
21
+ from kivy.properties import (
22
+ BooleanProperty,
23
+ ColorProperty,
24
+ ListProperty,
25
+ NumericProperty,
26
+ StringProperty,
27
+ )
28
+ from kivy.uix.behaviors import ToggleButtonBehavior
29
+
30
+
31
+ class CommonRipple:
32
+
33
+
34
+ ripple_rad_default = NumericProperty(1)
35
+
36
+
37
+ ripple_color = ColorProperty(None)
38
+
39
+ ripple_alpha = NumericProperty(0.5)
40
+
41
+
42
+ ripple_scale = NumericProperty(None)
43
+
44
+
45
+ ripple_duration_in_fast = NumericProperty(0.3)
46
+
47
+
48
+ ripple_duration_in_slow = NumericProperty(2)
49
+
50
+
51
+ ripple_duration_out = NumericProperty(0.3)
52
+
53
+
54
+ ripple_canvas_after = BooleanProperty(True)
55
+
56
+
57
+ ripple_func_in = StringProperty("out_quad")
58
+
59
+ ripple_func_out = StringProperty("out_quad")
60
+
61
+
62
+ _ripple_rad = NumericProperty()
63
+ _doing_ripple = BooleanProperty(False)
64
+ _finishing_ripple = BooleanProperty(False)
65
+ _fading_out = BooleanProperty(False)
66
+ _no_ripple_effect = BooleanProperty(False)
67
+ _round_rad = ListProperty([0, 0, 0, 0])
68
+
69
+ def lay_canvas_instructions(self) -> NoReturn:
70
+ raise NotImplementedError
71
+
72
+ def start_ripple(self) -> None:
73
+ if not self._doing_ripple:
74
+ self._doing_ripple = True
75
+ anim = Animation(
76
+ _ripple_rad=self.finish_rad,
77
+ t="linear",
78
+ duration=self.ripple_duration_in_slow,
79
+ )
80
+ anim.bind(on_complete=self.fade_out)
81
+ anim.start(self)
82
+
83
+ def finish_ripple(self) -> None:
84
+ if self._doing_ripple and not self._finishing_ripple:
85
+ self._finishing_ripple = True
86
+ self._doing_ripple = False
87
+ Animation.cancel_all(self, "_ripple_rad")
88
+ anim = Animation(
89
+ _ripple_rad=self.finish_rad,
90
+ t=self.ripple_func_in,
91
+ duration=self.ripple_duration_in_fast,
92
+ )
93
+ anim.bind(on_complete=self.fade_out)
94
+ anim.start(self)
95
+
96
+ def fade_out(self, *args) -> None:
97
+ rc = self.ripple_color
98
+ if not self._fading_out:
99
+ self._fading_out = True
100
+ Animation.cancel_all(self, "ripple_color")
101
+ anim = Animation(
102
+ ripple_color=[rc[0], rc[1], rc[2], 0.0],
103
+ t=self.ripple_func_out,
104
+ duration=self.ripple_duration_out,
105
+ )
106
+ anim.bind(on_complete=self.anim_complete)
107
+ anim.start(self)
108
+
109
+ def anim_complete(self, *args) -> None:
110
+ self._doing_ripple = False
111
+ self._finishing_ripple = False
112
+ self._fading_out = False
113
+
114
+ if not self.ripple_canvas_after:
115
+ canvas = self.canvas.before
116
+ else:
117
+ canvas = self.canvas.after
118
+
119
+ canvas.remove_group("circular_ripple_behavior")
120
+ canvas.remove_group("rectangular_ripple_behavior")
121
+
122
+ def on_touch_down(self, touch):
123
+
124
+ super().on_touch_down(touch)
125
+ if touch.is_mouse_scrolling:
126
+ return False
127
+ if not self.collide_point(touch.x, touch.y):
128
+ return False
129
+ if not self.disabled:
130
+ self.call_ripple_animation_methods(touch)
131
+
132
+ if isinstance(self, ToggleButtonBehavior):
133
+ return super().on_touch_down(touch)
134
+ else:
135
+ return True
136
+
137
+ def call_ripple_animation_methods(self, touch) -> None:
138
+ if self._doing_ripple:
139
+ Animation.cancel_all(
140
+ self, "_ripple_rad", "ripple_color", "rect_color"
141
+ )
142
+ self.anim_complete()
143
+ self._ripple_rad = self.ripple_rad_default
144
+ self.ripple_pos = (touch.x, touch.y)
145
+
146
+ if self.ripple_color:
147
+ pass
148
+ elif hasattr(self, "theme_cls"):
149
+ self.ripple_color = self.theme_cls.ripple_color
150
+ else:
151
+ # If no theme, set Gray 300.
152
+ self.ripple_color = [
153
+ 0.8784313725490196,
154
+ 0.8784313725490196,
155
+ 0.8784313725490196,
156
+ self.ripple_alpha,
157
+ ]
158
+ self.ripple_color[3] = self.ripple_alpha
159
+ self.lay_canvas_instructions()
160
+ self.finish_rad = max(self.width, self.height) * self.ripple_scale
161
+ self.start_ripple()
162
+
163
+ def on_touch_move(self, touch, *args):
164
+ if not self.collide_point(touch.x, touch.y):
165
+ if not self._finishing_ripple and self._doing_ripple:
166
+ self.finish_ripple()
167
+ return super().on_touch_move(touch, *args)
168
+
169
+ def on_touch_up(self, touch):
170
+ if self.collide_point(touch.x, touch.y) and self._doing_ripple:
171
+ self.finish_ripple()
172
+ return super().on_touch_up(touch)
173
+
174
+ def _set_ellipse(self, instance, value):
175
+ self.ellipse.size = (self._ripple_rad, self._ripple_rad)
176
+
177
+ # Adjust ellipse pos here
178
+
179
+ def _set_color(self, instance, value):
180
+ self.col_instruction.a = value[3]
181
+
182
+
183
+ class RectangularRippleBehavior(CommonRipple):
184
+
185
+
186
+ ripple_scale = NumericProperty(2.75)
187
+
188
+ def lay_canvas_instructions(self) -> None:
189
+ if self._no_ripple_effect:
190
+ return
191
+
192
+ with self.canvas.after if self.ripple_canvas_after else self.canvas.before:
193
+ if hasattr(self, "radius"):
194
+ if isinstance(self.radius, (float, int)):
195
+ self.radius = [
196
+ self.radius,
197
+ ]
198
+ self._round_rad = self.radius
199
+ StencilPush(group="rectangular_ripple_behavior")
200
+ RoundedRectangle(
201
+ pos=self.pos,
202
+ size=self.size,
203
+ radius=self._round_rad,
204
+ group="rectangular_ripple_behavior",
205
+ )
206
+ StencilUse(group="rectangular_ripple_behavior")
207
+ self.col_instruction = Color(
208
+ rgba=self.ripple_color, group="rectangular_ripple_behavior"
209
+ )
210
+ self.ellipse = Ellipse(
211
+ size=(self._ripple_rad, self._ripple_rad),
212
+ pos=(
213
+ self.ripple_pos[0] - self._ripple_rad / 2.0,
214
+ self.ripple_pos[1] - self._ripple_rad / 2.0,
215
+ ),
216
+ group="rectangular_ripple_behavior",
217
+ )
218
+ StencilUnUse(group="rectangular_ripple_behavior")
219
+ RoundedRectangle(
220
+ pos=self.pos,
221
+ size=self.size,
222
+ radius=self._round_rad,
223
+ group="rectangular_ripple_behavior",
224
+ )
225
+ StencilPop(group="rectangular_ripple_behavior")
226
+ self.bind(ripple_color=self._set_color, _ripple_rad=self._set_ellipse)
227
+
228
+ def _set_ellipse(self, instance, value):
229
+ super()._set_ellipse(instance, value)
230
+ self.ellipse.pos = (
231
+ self.ripple_pos[0] - self._ripple_rad / 2.0,
232
+ self.ripple_pos[1] - self._ripple_rad / 2.0,
233
+ )
234
+
235
+
236
+ class CircularRippleBehavior(CommonRipple):
237
+
238
+
239
+ ripple_scale = NumericProperty(1)
240
+
241
+
242
+ def lay_canvas_instructions(self) -> None:
243
+ if self._no_ripple_effect:
244
+ return
245
+
246
+ with self.canvas.after if self.ripple_canvas_after else self.canvas.before:
247
+ StencilPush(group="circular_ripple_behavior")
248
+ self.stencil = Ellipse(
249
+ size=(
250
+ self.width * self.ripple_scale,
251
+ self.height * self.ripple_scale,
252
+ ),
253
+ pos=(
254
+ self.center_x - (self.width * self.ripple_scale) / 2,
255
+ self.center_y - (self.height * self.ripple_scale) / 2,
256
+ ),
257
+ group="circular_ripple_behavior",
258
+ )
259
+ StencilUse(group="circular_ripple_behavior")
260
+ self.col_instruction = Color(rgba=self.ripple_color)
261
+ self.ellipse = Ellipse(
262
+ size=(self._ripple_rad, self._ripple_rad),
263
+ pos=(
264
+ self.center_x - self._ripple_rad / 2.0,
265
+ self.center_y - self._ripple_rad / 2.0,
266
+ ),
267
+ group="circular_ripple_behavior",
268
+ )
269
+ StencilUnUse(group="circular_ripple_behavior")
270
+ Ellipse(
271
+ pos=self.pos, size=self.size, group="circular_ripple_behavior"
272
+ )
273
+ StencilPop(group="circular_ripple_behavior")
274
+ self.bind(
275
+ ripple_color=self._set_color, _ripple_rad=self._set_ellipse
276
+ )
277
+
278
+ def _set_ellipse(self, instance, value):
279
+ super()._set_ellipse(instance, value)
280
+ if self.ellipse.size[0] > self.width * 0.6 and not self._fading_out:
281
+ self.fade_out()
282
+ self.ellipse.pos = (
283
+ self.center_x - self._ripple_rad / 2.0,
284
+ self.center_y - self._ripple_rad / 2.0,
285
+ )
@@ -0,0 +1,34 @@
1
+ from kivy.uix.accordion import StringProperty
2
+ from kivy.uix.textinput import TextInput
3
+ from .utils import ar
4
+
5
+ __all__=('ArTextInput','ArTextInputBase',)
6
+
7
+ class ArTextInput(TextInput):
8
+ t=StringProperty()
9
+ def __init__(self, **kwargs):
10
+ super().__init__(**kwargs)
11
+ self.base_direction='rtl'
12
+ def insert_text(self, substring, from_undo=False):
13
+ self.t+=substring
14
+ self.text=ar(self.t)
15
+ def do_backspace(self, from_undo=False, mode='bkspc'):
16
+ self.t=self.t[:-1]
17
+ self.text=ar(self.t)
18
+
19
+
20
+ class ArTextInputBase:
21
+ t=StringProperty()
22
+ def __init__(self, **kwargs):
23
+ super().__init__(**kwargs)
24
+ self.base_direction='rtl'
25
+ def insert_text(self, substring, from_undo=False):
26
+ self.t+=substring
27
+ self.text=ar(self.t)
28
+ def do_backspace(self, from_undo=False, mode='bkspc'):
29
+ self.t=self.t[:-1]
30
+ self.text=ar(self.t)
31
+
32
+
33
+
34
+
@@ -0,0 +1,18 @@
1
+ from arabic_reshaper import reshape
2
+ from bidi.algorithm import get_display
3
+
4
+
5
+ def ar(text):
6
+ return get_display(reshape(text))
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.1
2
+ Name: arkivy
3
+ Version: 1.0
4
+ Summary: Help library with kivy in Arabic language formatting
5
+ Author: ALI KAZM
6
+
7
+
8
+
9
+ install library
10
+
11
+ ``pip instal arkivy``
12
+
13
+
@@ -0,0 +1,12 @@
1
+ setup.py
2
+ arkivy/__init__.py
3
+ arkivy/button.py
4
+ arkivy/label.py
5
+ arkivy/ripple.py
6
+ arkivy/textinput.py
7
+ arkivy/utils.py
8
+ arkivy.egg-info/PKG-INFO
9
+ arkivy.egg-info/SOURCES.txt
10
+ arkivy.egg-info/dependency_links.txt
11
+ arkivy.egg-info/requires.txt
12
+ arkivy.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+ arabic_reshaper
2
+ kivy
3
+ python_bidi
@@ -0,0 +1 @@
1
+ arkivy
arkivy-1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
arkivy-1.0/setup.py ADDED
@@ -0,0 +1,30 @@
1
+ from setuptools import setup,find_packages
2
+
3
+ d='''
4
+
5
+ install library
6
+
7
+ ``pip instal arkivy``
8
+
9
+
10
+ '''
11
+
12
+
13
+
14
+
15
+
16
+
17
+ setup(
18
+ version='1.0',
19
+ name='arkivy',
20
+ author='ALI KAZM',
21
+ description='Help library with kivy in Arabic language formatting',
22
+ packages=find_packages(),
23
+ long_description=d,
24
+ install_requires=['arabic_reshaper','python_bidi','kivy'],
25
+
26
+
27
+ )
28
+
29
+
30
+