CardTransition 在 Kivy 1.9.1 中不起作用
CardTransition isn't working in Kivy 1.9.1
我正在尝试在 kivy 中制作一个使用 CardTransition 的多屏幕简单应用程序,但是当我尝试 运行 它时,我得到了一个错误。我知道该应用程序本身可以正常工作,因为我已经尝试过不同的过渡并且它运行良好。我正在使用 Python 3.4.4 和 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'
CardTransition 仅在 kivy 1.10 中添加。
我正在尝试在 kivy 中制作一个使用 CardTransition 的多屏幕简单应用程序,但是当我尝试 运行 它时,我得到了一个错误。我知道该应用程序本身可以正常工作,因为我已经尝试过不同的过渡并且它运行良好。我正在使用 Python 3.4.4 和 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'
CardTransition 仅在 kivy 1.10 中添加。