2017-10-29 1 views
2

kivy에서 애니메이션 도구를 사용하여 레이블의 일부 텍스트를 페이드하고 싶지만 작동시키지 못하고 어디에서나 인터넷에서 아무 것도 찾을 수 없습니다. 을 Heres 코드 :Kivy Label 텍스트가 희미합니다.

평 : Animation

  • opacity=1

    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" 
    
  • 답변

    1
    • 변화 Animate 레이블 표시 의미, 당신이 원하는 무엇 opacity=0
    • 입니다
    • 당신은 어딘가에 animate 기능 다음

    완전히 예를 작동하고 (파이썬 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() 
    
    +0

    이 감사합니다,하지만 우리는 그 __init__ 일이 XD –

    +0

    를 데프 둘 필요가 난 아직도 왜하지 않습니다 @ HussamAl-hassan'animate'는 수업의 한 방법 일뿐입니다. 애니메이션을 시작하려면 어딘가에 전화해야합니다. '__init__' (위젯 생성시), 일부 버튼 누름, 일부 요소 클릭 - 원하는 곳 어디서나 원하는대로 호출 할 수 있습니다. –

    +0

    오류가 발생했습니다. TypeError : 'NoneType'개체를 호출 할 수 없습니다. –