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:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course