Kivy is a platform independent 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 Desktop applications.
Use this command To install kivy:
pip install kivy
Gridlayout is the function which creates the children and arrange them in a matrix format. It takes the available space(square) and divides that space into rows and columns then add the widgets accordingly to the resulting cells or grids.
We can not explicitly place the widgets in a particular column/row. Each child is assigned a particular position automatically determined by the layout configuration and the child index in children list. A
gridlayout must contain at least on input constraints i.e. cols and rows. If we do not specify the cols or rows to it, the layout gives you an exception.
Coloumn and Row –
Now the Coulums represent the width and the rows represents the hight just like matrix.
- Initial the size is given by the
row_default_heightproperties. We can force the default size by setting the
row_force_defaultproperty. This will force the layout to ignore the width and size_hint properties of children and use the default size.
- To customize the size of a single column or row, use
- It is not necessary to give both rows and columns, it depends on the requirement. We can provide either both or anyone accordingly.
In the given below example, all the widgets will have the same or equal size. By default, the size is (1, 1) so the child will take full size of the parent.
Note : For understanding how to use
.kv files, just visit this.
Note: To run this code you have to make the
main.py python file for the above python code and another file
Now let’s fix the size of the buttons to 100px instead of default size_hint_x = 1.
We can also fix the row hight to a specific size.
- Python | Kivy .kv File
- Introduction to Kivy ; A Cross-platform Python Framework
- Python | Ellipse (different polygons) in Kivy
- Python | Scrollview widget in kivy
- Python | Carousel Widget In Kivy
- Python | Float Layout in Kivy
- Python | Make a simple window using kivy
- Python | Working with buttons in Kivy
- Python | Add Label to a kivy window
- Python | Button Action in Kivy
- Python | Window size Adjustment in Kivy
- Python | BoxLayout widget in Kivy
- Python | Slider widget in Kivy
- Python | Checkbox widget in Kivy
- Python | Multiple Sliders widgets Controlling Background Screen or WindowColor in Kivy
- Python | AnchorLayout in Kivy using .kv file
- Python| AnchorLayout in Kivy
- Python | StackLayout in Kivy
- Python | StackLayout in Kivy using .kv file
- Python | FloatLayout in Kivy using .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 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.