Using the basics: buttons, labels, and text inputs
Here, we will work with basic widgets as the first approach to the chapter topic. In our task, we will develop an app that has three elements: a text input, a button, and a label. Using this, the user can modify the label by pressing the button, by moving the cursor into the text input, or by changing the text input.
Getting ready
In the following few recipes, we are going to intensively use Kv language, so it is important for you to read Chapter 1, Kivy and the Kv language or at least the recipe Accessing widgets defined inside Kv language in your Python code from the first chapter.
How to do it…
To complete the task, follow these steps:
In the KV file, define a label.
Also define the button with an
on_press reference
method to a callback method.The text input with
on_focus reference
to another callback method is:<MyW>: Label: id: label1 pos: 300,200 text: 'Hello' Button: id: button1 pos:...