Python | TextInput in kivy using .kv file
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.
The TextInput widget provides a box for editable plain text. Unicode, multiline, cursor navigation, selection and clipboard features are supported.
The TextInput uses two different coordinate systems:
- (x, y) – coordinates in pixels, mostly used for rendering on screen.
- (row, col) – cursor index in characters / lines, used for selection and cursor movement.
Basic Approach: 1) import kivy 2) import kivyApp 3) import widger 4) import Relativelayout 5) import textinput 6) Set minimum version(optional) 7) Create Widget class 8) Create App class 9) create .kv file (name same as the app class): 1) create textinput 10) return Layout/widget/Class(according to requirement) 11) Run an instance of the class
Implementation of the Approach
# main.py file
# main.kv file
When you run the App you will see:
After some input you will see:
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