Hello guys!
I'm trying to animate the size of an image, so that when I click a button the image increases it's size. My code is the following:
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.animation import Animation
Builder.load_string("""
<MainScreen>:
Button:
on_release: root.animate_image()
BoxLayout:
orientation: "vertical"
size: self.parent.size
pos: self.parent.pos
BoxLayout:
orientation: "horizontal"
size_hint_y: 0.3
Image:
id: img_anim
source: "image.png"
size_hint_y: 0.4
allow_stretch: True
Label:
pos: self.parent.pos
size: self.parent.size
BoxLayout:
orientation: "horizontal"
size_hint_y: 0.3
""")
class MainScreen(Screen):
def animate_image(self):
anim = Animation(size=(500, 500), d=1.)
anim.start(self.ids["img_anim"])
sm = ScreenManager()
sm.add_widget(MainScreen(name='main'))
class MainApp(App):
def build(self):
sm.current = 'main'
return sm
if __name__ == '__main__':
MainApp().run()
This is not working. However, when I try to animate the image's position, it works. Why is that? Can you help me solve it? :)
Thanks!