Evolving to the touchscreen
In this recipe, we are evolving to the touchscreen. Here, you will see the basic differences between the mouse and the touchscreen. This will give us more options than with the mouse device.
Getting ready
For this recipe, we will use the Kv language for the design of the widgets, so make sure that you are confident with it and refresh your knowledge if necessary. Also, this recipe will use the common button and label widgets for reference. Obviously, to get more benefit, a touchscreen device is useful to run the code.
How to do it…
Perform the following steps:
In the KV file, declare the button and the label:
<MyW>: Button: id: button1 text: 'Hello' Label: id: label1 pos: 100, 100 text: 'My label before press the screen'
In the class of the widget in the Python code, we need to override the method
on_touch_down
Change the button text with the information in
touch.button
Change the label text with the information in...