我一直在尝试使用 kivy 创建一个带有某种动画的登录页面。但是,每次我运行脚本时,在关闭每一行代码后,它会为代码“size = self.size”的第 17 行显示“无效的属性名称”,这里我留下了迄今为止的代码 请帮助
from kivy.animation import Animation
from kivy.uix import widget
from kivy.uix.screenmanager import ScreenManager
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.core.window import Window
Window.size = (305, 480)
KV = """
MDScreen:
name: "LoginPage"
on_enter:
app.anim(back)
app.anim1(back1)
MDfloatLayout:
MDfloatLayout:
id: back
size_hint_y: .6
pos_hint: {"center_y": 1.8}
radius: [0, 0, 0, 40]
canvas:
color:
rgb: (1, 0, 0, 1)
rectangle:
size = self.size
pos = self.pos
MDfloatLayout:
id: back1
size_hint_y: .6
pos_hint: {"center_y": 1.8}
radius: [0, 0, 0, 40]
canvas:
color:
rgb: (1, 0, 0, 1)
Ellipse:
size = self.size
pos = self.pos
"""
class LoginApp(MDApp):
def change_screen(self, name):
screen_manager.current = name
def build(self):
global screen_manager
screen_manager = ScreenManager()
screen_manager.add_widget(Builder.load_string(KV))
return screen_manager
def anim(self):
anim = Animation(pos_hint={"center_y": 1.16})
anim.start(widget)
def anim1(self):
anim = Animation(pos_hint={"center_y": .85})
anim.start(widget)
if __name__ == "__main__":
app = LoginApp()
app.run()