first commit

This commit is contained in:
Yura 2024-09-15 15:12:16 +03:00
commit 417e54da96
5696 changed files with 900003 additions and 0 deletions

View file

@ -0,0 +1,3 @@
title=main
author=seesaw
orientation=portrait

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 KiB

View file

@ -0,0 +1,63 @@
#:kivy 1.0.9
<AnimatedButton>:
canvas.before:
Color:
rgb: (1, 1, 1)
BorderImage:
border: root.border if root.border else (16, 16, 16, 16)
pos: self.pos
size: self.size
texture: self.texture_background
<gifScatter>
on_size: self.center = win.Window.center
size: imag.size
size_hint: None, None
Image:
id: imag
source: 'data/images/simple_cv_joint_animated.gif'
on_touch_down: root.parent.parent.parent.currentObj = self
<zipScatter>
on_size: self.center = win.Window.center
size: imag.size
size_hint: None, None
Image:
id: imag
source: 'data/images/cube.zip'
anim_delay: 0.05
on_touch_down: root.parent.parent.parent.currentObj = self
<jpgScatter>
on_size: self.center = win.Window.center
size: imag.size
size_hint: None, None
Image:
id: imag
source: 'data/images/bird.zip'
on_touch_down: root.parent.parent.parent.currentObj = self
<Right_Frame>
size_hint: (.2, 1)
padding: 10
cols: 1
canvas:
Color:
rgba: .1,.45,.31,.9
Rectangle:
pos: self.pos
size:self.size
Label:
halign: 'center'
text_size: self.size
text: root.currentObj.source if root.currentObj else 'click on a Image to change it\'s properties'
Label:
id: spdlbl
halign: 'center'
text_size: self.size
text: 'No Image selected' if not root.currentObj else 'Animation speed: %f FPS' %(1/root.currentObj.anim_delay) if root.currentObj.anim_delay > 0 else 'Animation speed: 0 FPS'
Slider:
min:0
max: 100 if root.currentObj else 0
value: (1/root.currentObj.anim_delay) if (root.currentObj and root.currentObj.anim_delay>0) else 0
on_value: root.on_value(self, args[1], spdlbl)

View file

@ -0,0 +1,150 @@
import kivy
kivy.require('1.0.8')
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.gridlayout import GridLayout
from uix.custom_button import AnimatedButton
from kivy.uix.scatter import Scatter
from kivy.properties import ObjectProperty
class gifScatter(Scatter):
def __init__(self, **kwargs):
super(gifScatter, self).__init__()
class zipScatter(Scatter):
def __init__(self, **kwargs):
super(zipScatter, self).__init__()
class jpgScatter(Scatter):
def __init__(self, **kwargs):
super(jpgScatter, self).__init__()
class Right_Frame(GridLayout):
currentObj = ObjectProperty(None)
def __init__(self, **kwargs):
super(Right_Frame, self).__init__()
def on_value(self, *l):
if self.currentObj:
if abs(l[1]) <= 0:
self.currentObj.anim_delay = -1
l[2].text = 'Animation speed: %f FPS' % 0
else:
self.currentObj.anim_delay = 1 / l[1]
l[2].text = 'Animation speed: %f FPS' % (
1 / self.currentObj.anim_delay)
else:
l[0].max = 0
l[2].text = 'No Image selected'
class mainclass(FloatLayout):
currentObj = ObjectProperty(None)
def __init__(self, **kwargs):
super(mainclass, self).__init__()
# initialize variables
self.sign = .10
# setup Layouts
layout = GridLayout(size_hint=(1, 1), cols=3, rows=1)
left_frame = GridLayout(size_hint=(.25, 1), cols=1)
client_frame = FloatLayout(size_hint=(1, 1))
self.right_frame = Right_Frame()
# setup buttons in left frame
but_load_gif = AnimatedButton(text='load gif', halign='center')
but_load_zip_png = AnimatedButton(text='load zipped\n png/s',
halign='center')
but_load_zip_jpg = AnimatedButton(text='load zipped\n jpg/s',
halign='center')
but_animated = AnimatedButton(text='animated button\n'
'made using\nSequenced Images\n press to animate',
halign='center',
background_normal='data/images/button_white.png',
background_down='data/images/button_white_animated.zip')
but_animated_normal = AnimatedButton(text='borderless\n'
'animated button\npress to stop',
halign='center',
background_down='data/images/button_white.png',
background_normal='data/images/button_white_animated.zip')
but_animated_borderless = AnimatedButton(text='Borderless',
background_normal='data/images/info.png',
background_down='data/images/info.zip', halign='center')
but_animated_bordered = AnimatedButton(text='With Border',
background_normal='data/images/info.png',
background_down='data/images/info.zip', halign='center')
# Handle button press/release
def load_images(*l):
if l[0].text == 'load gif' or l[0].text == 'load gif\n from cache':
l[0].text = 'load gif\n from cache'
sctr = gifScatter()
if (l[0].text == 'load zipped\n png/s' or
l[0].text == 'load zipped\n png/s from cache'):
l[0].text = 'load zipped\n png/s from cache'
sctr = zipScatter()
if (l[0].text == 'load zipped\n jpg/s' or
l[0].text == 'load zipped\n jpg/s from cache'):
l[0].text = 'load zipped\n jpg/s from cache'
sctr = jpgScatter()
client_frame.add_widget(sctr, 1)
# position scatter
sctr.pos = (240 + self.sign, 200 + self.sign)
self.sign += 10
if self.sign > 200:
self.sign = 10
sctr.pos = (300, 200 - self.sign)
# bind function on on_release
but_load_gif.bind(on_release=load_images)
but_load_zip_png.bind(on_release=load_images)
but_load_zip_jpg.bind(on_release=load_images)
# add widgets to left frame
left_frame.add_widget(but_load_gif)
left_frame.add_widget(but_load_zip_png)
left_frame.add_widget(but_load_zip_jpg)
left_frame.add_widget(but_animated)
left_frame.add_widget(but_animated_normal)
left_frame.add_widget(but_animated_borderless)
left_frame.add_widget(but_animated_bordered)
# set/remove border for borderless widgets (16,16,16,16) by default
but_animated_normal.border = \
but_animated_borderless.border = (0, 0, 0, 0)
# add widgets to the main layout
layout.add_widget(left_frame)
layout.add_widget(client_frame)
layout.add_widget(self.right_frame)
# add main layout to root
self.add_widget(layout)
def on_currentObj(self, *l):
self.right_frame.currentObj = self.currentObj
class mainApp(App):
def build(self):
upl = mainclass()
upl.size_hint = (1, 1)
upl.pos_hint = {'top': 0, 'right': 1}
return upl
if __name__ == '__main__':
mainApp().run()

View file

@ -0,0 +1,7 @@
'''
UIX
===
The `uix` contains all the class for creating and arranging Custom Widgets.
A widget is an element of a graphical user interface.
'''

View file

@ -0,0 +1,98 @@
__all__ = ('AnimatedButton')
from kivy.factory import Factory
from kivy.uix.label import Label
from kivy.uix.image import Image
from kivy.properties import StringProperty, OptionProperty, \
ObjectProperty, BooleanProperty
class AnimatedButton(Label):
state = OptionProperty('normal', options=('normal', 'down'))
fit_mode = StringProperty("fill")
border = ObjectProperty(None)
anim_delay = ObjectProperty(None)
background_normal = StringProperty(
'atlas://data/images/defaulttheme/button')
texture_background = ObjectProperty(None)
background_down = StringProperty(
'atlas://data/images/defaulttheme/button_pressed')
def __init__(self, **kwargs):
super(AnimatedButton, self).__init__(**kwargs)
self.register_event_type('on_press')
self.register_event_type('on_release')
# borderImage.border by default is ...
self.border = (16, 16, 16, 16)
# Image to display depending on state
self.img = Image(
source=self.background_normal,
fit_mode=self.fit_mode,
mipmap=True)
# reset animation if anim_delay is changed
def anim_reset(*l):
self.img.anim_delay = self.anim_delay
self.bind(anim_delay=anim_reset)
self.anim_delay = .1
# update self.texture when image.texture changes
self.img.bind(texture=self.on_tex_changed)
self.on_tex_changed()
# update image source when background image is changed
def background_changed(*l):
self.img.source = self.background_normal
self.anim_delay = .1
self.bind(background_normal=background_changed)
def on_tex_changed(self, *largs):
self.texture_background = self.img.texture
def _do_press(self):
self.state = 'down'
def _do_release(self):
self.state = 'normal'
def on_touch_down(self, touch):
if not self.collide_point(touch.x, touch.y):
return False
if repr(self) in touch.ud:
return False
touch.grab(self)
touch.ud[repr(self)] = True
_animdelay = self.img.anim_delay
self.img.source = self.background_down
self.img.anim_delay = _animdelay
self._do_press()
self.dispatch('on_press')
return True
def on_touch_move(self, touch):
return repr(self) in touch.ud
def on_touch_up(self, touch):
if touch.grab_current is not self:
return
assert repr(self) in touch.ud
touch.ungrab(self)
_animdelay = self.img._coreimage.anim_delay
self.img.source = self.background_normal
self.anim_delay = _animdelay
self._do_release()
self.dispatch('on_release')
return True
def on_press(self):
pass
def on_release(self):
pass
Factory.register('AnimatedButton', cls=AnimatedButton)