2017-05-03 71 views
0

我想在多個使用CardTransition的屏幕上製作一個簡單的kivy應用程序,但是當我嘗試運行它時出現錯誤。我知道該應用程序本身的作品,因爲我已經嘗試過一個不同的轉換,並且工作正常。我在Kivy 1.9.1上使用Python 3.4.4。CardTransition在Kivy 1.9.1中不工作

下面的代碼:

import kivy 
kivy.require("1.9.1") 

from kivy.uix.boxlayout  import BoxLayout 
from kivy.app    import App 
from kivy.uix.label   import Label 
from kivy.uix.button  import Button 
from kivy.lang    import Builder 
from kivy.uix.screenmanager import ScreenManager, Screen, SwapTransition, CardTransition 

KivyFile = Builder.load_string(""" 
<Screen1>: 
    name: "Screen1" 
    BoxLayout: 
     orientation: "vertical" 
     padding: 40 
     spacing: 20 

     Label: 
      text: "This is screen 1" 
     Button: 
      text: "Next Screen" 
      on_release: app.root.current = "Screen2" 
<Screen2>: 
    name: "Screen2" 
    BoxLayout: 
     orientation: "vertical" 
     padding: 40 
     spacing: 20 

     Label: 
      text: "This is screen 2" 
     Button: 
      text: "Next Screen" 
      on_release: app.root.current = "Screen3" 
<Screen3>: 
    name: "Screen3" 
    BoxLayout: 
     orientation: "vertical" 
     padding: 40 
     spacing: 20 

     Label: 
      text: "This is screen 3" 
     Button: 
      text: "Next Screen" 
      on_release: app.root.current = "Screen1" 
""") 

class Screen1(Screen): 
    pass 

class Screen2(Screen): 
    pass 

class Screen3(Screen): 
    pass 

sm = ScreenManager(transition=CardTransition()) 
sm.add_widget(Screen1(name = "Screen1")) 
sm.add_widget(Screen2(name = "Screen2")) 
sm.add_widget(Screen3(name = "Screen3")) 

class MyApp(App): 

    def build(self): 
     return sm 

if __name__ == "__main__": 
    MyApp().run() 

這是我得到的錯誤:

Traceback (most recent call last): 
    File "C:/Users/Markus/Desktop/Kivy/TestTransitions.py", line 9, in <module> 
    from kivy.uix.screenmanager import ScreenManager, Screen, SwapTransition, CardTransition 
ImportError: cannot import name 'CardTransition' 

回答

0

CardTransition只在kivy 1.10加。