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.
Spinner widget :
To work with spinner you must have to import:
from kivy.uix.spinner import Spinner
Spinner is a widget that provides a quick way to select one value from a set. In the default state, a spinner shows its currently selected value. Touching the spinner displays a dropdown menu with all the other available values from which the user can select a new one.
Like a combo box, a spinner object can have multiple values and one of the values can be selected.
A callback can be attached to the spinner object to receive notifications on selection of a value from the spinner object.
Basic Approach: 1) import kivy 2) import kivyApp 3) import spinner 4) import Floatlayout(according to need) 5) import window(optional) 6) Set minimum version(optional) 7) Create Layout class: define the clicked function in it 8) Create App class 9) create .kv file (name same as the app class): 1) create Spinner 2) create callback 3) And many more styling as needed 10) return Layout/widget/Class(according to requirement) 11) Run an instance of the class
Below is the implementation :
In the below code we have created the spinner and done the sizing and positioning and also attached the callback to the values.
.kv file of the code:
Below is the output in video to get better understanding:
- Python | Spinner widget in kivy
- Python | Switch 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
- Python | Carousel Widget In Kivy
- Python | Progress Bar widget in kivy
- Python | Switch widget in Kivy
- Python | Popup widget in Kivy
- Python | Slider widget in Kivy
- Python | Textinput widget in kivy
- Python | Add image widget in Kivy
- Python | Scrollview widget in kivy
- Python | BoxLayout widget in Kivy
- Python | Checkbox widget in Kivy
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.