2017-05-03 72 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加。