Organizing with layouts
Sometimes, it is quite tedious to establish each and every position for all the widgets in our app. There is a special kind of widget, the layouts widget, that makes things easy for us. In this recipe, we will review how to work with the size and position hints that allows us to organize widgets inside this new kind of widget.
Getting ready
A quick check of the recipe Designing with the Kv language in Chapter 1, Kivy and the Kv language could be important to go deeper in this recipe.
How to do it…
To complete the task, perform the following steps:
In the KV file, define two buttons and assign the
size_hint
andpos_hint
properties as follows:<MyW1>: Button: id: label1 size_hint: .2, .2 pos_hint: {'center_x':.5, 'center_y': .5} text: 'B1' Button: id: label2 size_hint: .1, .1 pos_hint: {'center_x':.1, 'center_y': .1} text: 'B2'
In the Python file, import the
FloatLayout
.Define the class for the...