Kivy is a platform independent GUI tool in Python. As it can be run on Android, IOS, linux and Windows etc. Kivy provides you the functionality to write the code for once and run it on different platforms. It is basically used to develop the Android application, but it does not mean that it can not be used on Desktops applications.
Now in this article, we will learn about the use of Box layout widget in kivy using the
.kv file and how to add some features like color, size etc to it.
Kivy offers several layouts to keep the widgets at the desired places on an application. BoxLayout is a simple yet powerful layout often used either in a nested way or in a simple plain way. BoxLayout arranges widgets in either in a vertical fashion that is one on top of another or in a horizontal fashion that is one after another. When you will not provide any size-hint then the child widgets divides the size of its parent widget equally or accordingly.
Basic Approach to follow while creating button :
1) import kivy
2) import kivyApp
3) import BoxLayout
4) set minimum version(optional)
5) Extend the class
6) set up .kv file (name same as the Appclass)
7) Return layout
8) Run an instance of the class
main.pyfile of BoxLayout –
KVBoxLayout.kv file of
1) When orientation set is Vertical
2) When orientation set is Horizontal
- PYGLET – On Layout Update Event for Incremental Text Layout
- Python | Relative Layout in Kivy using .kv file
- Python | Grid Layout in Kivy without .kv file
- wxPython - Create Static Box using Create() method
- Python | Slider widget using .kv file
- Python | Switch widget in Kivy using .kv file
- Python | Spinner widget in Kivy using .kv file
- Python | Popup widget in Kivy using .kv file
- Python | Carousel Widget In Kivy using .kv file
- Python | Progressbar widget in kivy using .kv file
- Create a GUI to convert CSV file into excel file using Python
- Working with Input box/Test Box in Selenium with Python
- How to create Label widget in PyQt5 ?
- Create Find and Replace features in Tkinter Text Widget
- PyQt5 - Check box checked state depending upon another check box
- PyQt5 - How to hide the items from drop down box in Combo Box
- Create a Yes/No Message Box in Python using tkinter
- Text Input box with a verification button in kivy (using .kv file)
- Python | Create a stopwatch using clock object in kivy using .kv file
- Raise a File Download Dialog Box in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.