我正试图在kivy中使用动画工具制作标签中的一些文字,但我无法让它工作,我发现互联网上的任何东西都没有帮助。 下面是代码:
的.py:
class TestScreen(Screen):
def animate (self):
anim = Animate(opacity=1, duration=2)
anim.start(self.lbl)
.kv
<TestScreen>
lbl: label
Label
id: label
text: "Welcome"
答案 0 :(得分:1)
Animate
Animation
opacity=1
表示标签可见,您想要的是opacity=0
animate
函数
某处这里有完整的工作示例(Python 2.7):
from __future__ import absolute_import, division, print_function, unicode_literals
__metaclass__ = type
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen
from kivy.animation import Animation
Builder.load_string(b'''
<RootWidget>:
lbl: label
Label
id: label
text: "Welcome"
''')
class RootWidget(Screen):
def __init__(self, **kwargs):
super(RootWidget, self).__init__(**kwargs)
self.animate()
def animate(self):
anim = Animation(opacity=0, duration=2)
anim.start(self.lbl)
class TestApp(App):
def build(self):
return RootWidget()
if __name__ == '__main__':
TestApp().run()