Kivy is a platform independent GUI tool in Python. As it can be run on Android, IOS, linux and Windows etc. It is basically used to develop the Android application, but it does not mean that it can not be used on Desktops applications.
The PageLayout works in a different manner from other layouts. It is a dynamic layout, in the sense that it allows flipping through pages using its borders. The idea is that its components are stacked in front of each other, and we can just see the one that is on top.
PageLayout is similar to pages of a copy like that we can move/change the pages right or left.
PageLayout class is used to create a simple multi-page layout, in a way that allows easy flipping from one page to another using border.
To use PageLayout you have to import it by the below command:
from kivy.uix.pagelayout import PageLayout
PageLayout does not currently honor the size_hint, size_hint_min, size_hint_max, or pos_hint properties. That means we can not use all these in a page layout.
PageLayout: Button: text: 'page1' Button: text: 'page2' Button: text: 'page3'
Transitions from one page to the next are made by swiping in from the border areas on the right or left-hand side. If you want to use multiple widgets on a page, use layouts to do that. Ideally, each page should consist of a single layout widget that contains the remaining widgets on that page.
Page Layout contains many things which can be used to make it more effective easily in
- border: The width of the border around the current page used to display the previous/next page swipe areas when needed. border is a NumericProperty and defaults to 50dp.
- page: The currently displayed page. Page is a NumericProperty and defaults to 0.
- swipe_threshold: The threshold used to trigger swipes as percentage of the widget size. swipe_threshold is a NumericProperty and defaults to .5.
1) import kivy 2) import kivyApp 3) import Pagelayout 4) Set minimum version(optional) 5) create Layout class 6) create App class - create build() function 7) Set up .kv file(name same as the App class) 8) return Layout/widget/Class(according to requirement) 9) Run an instance of the class
Below is the Implementation for .kv files in this code :
1). kv file is just Simply how to create pages in .kv file
2). kv file is how can yo add features like : color, text, image, canvas, swipe_threshold, button in the pages.
Implementation of the Approach –
1) .kv file of Simple pages
Page 1 image
Page 2 image
Similar is Page 3 and 4.
2) .kv file with some features on pages
- Python | PageLayout in Kivy
- Python | Kivy .kv File
- Python | StackLayout in Kivy using .kv file
- Python | File chooser in kivy
- Python | AnchorLayout in Kivy using .kv file
- Python | Animation in Kivy using .kv file
- Python | ScreenManager in Kivy using .kv file
- Python | Canvas in Kivy using .kv file
- Python | TextInput in kivy using .kv file
- Python | FloatLayout in Kivy using .kv file
- Python | Accordion in kivy using .kv file
- Python | Progressbar widget in kivy using .kv file
- Python | Carousel Widget In Kivy using .kv file
- Python | Drop-down list in kivy using .kv file
- Python | Grid Layout in Kivy without .kv file
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.