Designing with the Kv language
This recipe will give you a first look at the widgets' distribution and their interaction.
Getting ready
This recipe will use two common widgets, just for reference; again we'll be looking at the Button
and TextInput
fields. Also, a common kind of layout is BoxLayout
, which controls the distribution of objects in the interface.
How to do it…
This recipe works by performing the following steps:
- First, the KV file:
<Controller>: label_wid: my_custom_label BoxLayout: orientation: 'horizontal' padding: 20 Button: text: 'My controller info is: ' + root.info on_press: root.do_action() Label: id: my_custom_label text: 'My label before button press'
- Next, the Python code:
import kivy kivy.require('1.8.0') from kivy.uix.floatlayout ...
Get Kivy Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.