in Animation class, how to set d = 0.4, t = 'in_out_quad' by default? Can I use subclass for that?
from kivy.app import App
from kivy.lang import Builder
from kivy.animation import Animation
KV = """
Label
text: '123'
on_touch_down: app.test()
"""
class MyApp(App):
def build(self):
self.root = Builder.load_string(KV)
def test(self):
a = Animation(x = 500, d = .2, t = 'in_out_quad')
a.start(self.root)
MyApp().run()
Tried something like this (with no success):
from kivy.app import App
from kivy.lang import Builder
from kivy.animation import Animation
KV = """
Label
text: '123'
on_touch_down: app.test()
<MyAnim>:
d: .2
t: 'in_out_quad'
"""
class MyAnim(Animation):
pass
class MyApp(App):
def build(self):
self.root = Builder.load_string(KV)
def test(self):
a = MyAnim(x = 500)
a.start(self.root)
MyApp().run()
I just want not to write the values of the arguments d and t many times if they are the same in my project
I haven't tested this, but I think you could just put those defaults in your class definition:
Of course, if you use
MyAnim
and specify anothert=
ord=
, you will get an error.That error can be avoided by only adding the default values if they are not already specified: