0
我正在嘗試動畫應用。它顯示一個錯誤代碼,說構建需要兩個參數(1給出)。這裏是我的代碼:Kivy Python出現動畫錯誤?
from kivy.app import App
from kivy.uix.image import Image
from kivy.animation import Animation
class TheApp(App):
def build(self, instance):
self.instance= instance
image = Image(source= "psychTREE.jpg")
image.allow_stretch= True
animation = Animation(pos= (100, 100), t= "out_bounce")
animation += Animation(pos= (200, 100), t = "out_bounce")
animation &= Animation(size= (500, 500))
animation += Animation(size= (100, 50))
image = animation.start(instance)
return image
if __name__ == "__main__":
TheApp().run()
但我想我已經在build(self,instance)中添加了第二個參數。我用self.instance = instance進一步初始化它。所以我不明白你在說什麼?我應該如何解決這個問題? –
您定義了一個函數,該函數*接受*第二個參數,但是當函數實際上由kivy調用時,它不會被賦予第二個參數,因此失敗。我不確定你期望的實例是什麼。 – inclement
我明白你的意思了,但我不知道如何給出第二個參數,你能不能發一個代碼片段來給出一些進一步的理解? –