PageLayout类似于动态布局,使用PageLayout可以创建一个简单的多页面布局,可以在这些页面间翻转。但是该布局将子控件作为一个单独的页面,所以不支持size_hint和pos_hint等属性。
实现代码,.kv文件
<PageLayoutWin>: anim_kwargs:{'d':5,'t':'linear'} page:2 swipe_threshold:.8 border:'100dp' Button: text:'page1' background_color:0.3,0.3,0.3,1 Button: text:'page2' background_color:0.9,0.3,0.3,1 Button: text:'page3' background_color:0.3,0.9,0.3,1 Button: text:'page4' background_color:0.3,0.3,0.9,1
定义页面,并添加4个按钮作为page。
anim_kwargs,设置翻页时动画,和持续的时间
page , 设置第几页为程序启动时的默认页
border,设置边界
swipe_threshold,设置翻页响应的灵敏度
.py文件代码
from kivy.app import App from kivy.uix.pagelayout import PageLayout class PageLayo