切换屏幕中的运动 [英] Swapping screens with motion in kivy

查看:81
本文介绍了切换屏幕中的运动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过移动而不是按按钮来交换屏幕?我问的是在移动应用程序中,用户经常在哪里期望这种行为.

Is it possible to swap screens with motion, rather than on button press? I am asking in context of mobile applications, where this behaviour is often expected by users.

推荐答案

您可以使用轮播小部件.例如:

You can use Carousel widget. For example:

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder

Builder.load_string("""
<MyWidget>:
    Carousel:
        BoxLayout:
            orientation: 'vertical'
            Label:
                text: "Screen 1"
            Label:
                text: "Some text"
        BoxLayout:
            orientation: 'vertical'
            Label:
                text: "Screen 2"
            BoxLayout:
                Button:
                    text: "1"
                Button:
                    text: "2"
                Button:
                    text: "3"
                Button:
                    text: "4"
        BoxLayout:
            orientation: 'vertical'
            Label:
                text: "Screen 3"
            Label:
                text: "Some other text"
""")

class MyWidget(BoxLayout):
    pass

class MyApp(App):
    def build(self):
        return MyWidget()

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

这篇关于切换屏幕中的运动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆