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.
👉🏽 Kivy Tutorial – Learn Kivy with Examples.
TextInput:
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 widget
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
Python3
import kivy
from kivy.app import App
kivy.require( '1.9.0' )
from kivy.uix.widget import Widget
from kivy.uix.textinput import TextInput
from kivy.uix.relativelayout import RelativeLayout
class textinp(Widget):
pass
class MainApp(App):
def build( self ):
return textinp()
def process( self ):
text = self .root.ids. input .text
print (text)
if __name__ = = "__main__" :
MainApp().run()
|
# main.kv file
Python3
<textinp>:
title: 'InputDialog'
auto_dismiss: False
id : test1
RelativeLayout:
orientation: 'vertical'
pos: self .pos
size: root.size
id : test2
TextInput:
id : input
hint_text: 'Enter text'
pos_hint: { 'center_x' : 0.5 , 'center_y' : 0.705 }
size_hint: 0.95 , 0.5
on_text: app.process()
|
Output:
When you run the App you will see:

After some input you will see:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
28 Feb, 2022
Like Article
Save Article