Python Kivy How to Create TextInput

This is our eight article on Python Kivy, in this article we want to learn How to Create TextInput in Kivy. 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.

 

 

Kivy Crash Course Articles

1: Kivy Crash Course Introduction & Installation

2: Introduction to Kv Design Language 

3: Kivy Button with Callbacks

4: Kivy Layout Management 

5: How to Create CheckBox in Kivy

6: Kivy Image And AsyncImage Example

7: How to Create Slider in Python Kivy

 

 

 

Also you can watch the complete video for this article

 

 

 

 

So there are two ways that you can create TextInput in kivy, the first way is that you can create TextInput using the kivy.uix.textinput module, and the second way is using the kivy design language, so first let’s just do the first way.

 

 

 

This is the code for TextInput creation

 

In the above code we have just imported the TextInput module from kivy.uix, and after that we have created the object of TextInput, you can see that i also specified the font size for the TextInput, also i have disabled the multiline for the TextInput.

 

 

 

 

 

If you run the code this will be the result

Python Kivy How to Create TextInput
Python Kivy How to Create TextInput

 

 

 

 

 

So now let’s create the TextInput using the kivy file, first of all this is my python code. in this code basically i have just created a new class that extends from the Widget class and i have returned that class in my main app class.

 

 

 

 

 

Now this is our .kv file, and i have name the file textwindow.kv, make sure that this name should be similar to the main app class name, in my case it is TextWindow class.

 

 

 

 

So now if you run the code this will be the result

Kivy TextInput Example
Kivy TextInput Example

 

Subscribe and Get Free Video Courses & Articles in your Email

 

Share via
Copy link
Powered by Social Snap
×