【发布时间】:2016-09-07 01:09:19
【问题描述】:
我想知道如何使用 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 秒后消失,但它会等待应用启动,因此当应用加载时只有一个黑色窗口。
【问题讨论】:
标签: kivy splash-screen