Kivy Tutorials
About Lesson

In this Kivy Tutorial we are going to talk about Kivy 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.

 

 

First we want to create our Kivy TextInput using Python code, and you can use kivy.uix.textinput for this, so this is the complete code.

 

In the above code first we have created the object of TextInput, after that you can give the font size and we have made multiline to False, it means that we can not write multiline in the textinput, if you want Multiline than you can remove that.

 

 

Run the code and this is the result.

Kivy Tutorial - Kivy TextInput
Kivy Tutorial – Kivy TextInput

 

 

 

Now let’s create the TextInput using the kivy file, first of all create a new Python file and add the following codes in the file.

 

Our first class extends from the Widget class, and TextInput is related to the Widget class, when you extends from the widget class it means that you can access to all widgets of kivy, and in the second class we have just returned our TextInput class.

 

 

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.

 

In the kivy file we have defined some rules for MyTextInput class, and we have added width and height for the Kivy TextInput.

 

 

 

Run the complete code and this is the result.

Kivy Tutorial - Kivy TextInput
Kivy Tutorial – Kivy TextInput