Reputation:
So far, I have concocted code that will output an image. But when I try to animate it, I get a "build takes 2 arguments. 1 given" error.
import kivy
from kivy.app import App
from kivy.uix.image import Image
from kivy.animation import Animation
from kivy.uix.widget import Widget
class TheApp(App):
def build(self):
image = Image(source= "psychTREE.jpg")
image.allow_stretch= True
image= TheApp.animation()
image.animate()
return image
def animation(self, instance):
animate = Animation(pos = (100, 100), t= "out_bounce")
animate += Animation(pos= (200, 100), t = "out_bounce")
animate &= Animation(size = (500, 500))
animate += Animation(size = (100, 50))
animate.start(instance)
if __name__ == "__main__":
TheApp().run()
Any suggestions or ideas on how to fix this code would be greatly appreciated. I'm trying to animate the image so it moves side to side and up and down in the background screen.
Upvotes: 1
Views: 969
Reputation: 29488
You have multiple issues:
image= TheApp.animation()
image.animate()
animation
is a method of TheApp. You should call it via an instance, e.g. self.animation()
. With your way, you're calling it as a normal function and so it does not receive the implicit self
argument, hence the too few arguments problem.
animation
expects an argument beyond just the normally-implicit self (you named this instance
), but you do not pass one, so the function call is still invalid.
animation
doesn't return anything, so even if it worked this would set image
to None
.
Neither kivy.uix.image.Image, nor None, have an animate
method - so I don't know what you expect image.animate()
to do.
Upvotes: 2