ฉันต้องการทราบวิธีสร้างหน้าจอสแปลชด้วย kivy และแสดงรูปภาพให้จางลงในไม่กี่วินาที
สิ่งที่ดีที่สุดที่ฉันทำได้คือใช้รหัสนี้:
class MyApp(App):
def __init__(self, **kwargs):
super(MyApp, self).__init__(**kwargs)
self.splash_screen_image = Image(source='images/pyrat_icon.png', size=(0, 0))
Clock.schedule_once(self.start_anim, .01)
def build(self):
self.main_widget = MainWidget()
return self.main_widget
def start_anim(self, dt):
self.splash_screen_image.pos = (self.main_widget.center_x, self.main_widget.center_y)
self.main_widget.add_widget(self.splash_screen_image)
animation = Animation(x=self.main_widget.center_x - 35, y=self.main_widget.center_y - 35, height=70, width=70, d=2,
t='in_quad')
animation.start(self.splash_screen_image)
Clock.schedule_once(self.end_anim, 3)
def end_anim(self, dt):
self.main_widget.remove_widget(self.splash_screen_image)
สิ่งนี้จะแสดงโลโก้ของฉันบนหน้าจอและหายไปหลังจากผ่านไป 3 วินาที แต่จะรอให้แอปเริ่มทำงาน ดังนั้นเมื่อแอปกำลังโหลดจึงมีเพียงหน้าต่างสีดำเท่านั้น