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 Label 4) import Spinner 5) import Floatlayout 6) Set minimum version(optional) 7) create App class: 1) Create the spinner 2) Attach the labels to spinners 3) Attach a callback also 8) return Layout/widget/Class(according to requirement) 9) Run an instance of the class
Implementation of a simple spinner:
Now if we have to tell user every time which element in a list is selected, we will display a label just beside the spinner which tells about the selected label. Also, we will print the value, and text of spinner.
Below is the Implementation:
Below is the output in video to get better understanding:
- Python | Spinner widget in Kivy using .kv file
- Python | Textinput widget in kivy
- Python | Add image widget in Kivy
- Python | Slider widget in Kivy
- Python | BoxLayout widget in Kivy
- Python | Progress Bar widget in kivy
- Python | Scrollview widget in kivy
- Python | Switch widget in Kivy
- Python | Checkbox widget in Kivy
- Python | Carousel Widget In Kivy
- Python | Popup widget in Kivy
- Python | Switch widget in Kivy using .kv file
- Python | Popup widget in Kivy using .kv file
- Python | Progressbar widget in kivy using .kv file
- Python | Carousel Widget In Kivy using .kv file
- Python Tkinter - Frame Widget
- Python Tkinter - Menubutton Widget
- Python | PanedWindow Widget in Tkinter
- Python Tkinter - Checkbutton Widget
- Progressbar widget in Tkinter | 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.