Book Image

Kivy Blueprints

Book Image

Kivy Blueprints

Overview of this book

Table of Contents (17 chapters)
Kivy Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
The Python Ecosystem
Index

Setting the line thickness


The last and easiest feature that we are going to implement is a simple line thickness selector. As you can see in the following screenshot, we're reusing assets and styles from the previous part, the color palette.

Line width selector

This UI uses yet another RadioButton subclass, unimaginatively named LineWidthButton. Append the following declaration to the paint.kv file:

<LineWidthButton@ColorButton>:
    group: 'line_width'
    on_release: app.canvas_widget.set_line_width(self.text)
    color: C('#2C3E50')
    background_color: C('#ECF0F1')

Key differences from ColorButton are highlighted in the preceding code. These new buttons belong to another radio group and fire another event handler when interacted with. Other than this, they are very similar.

The layout is equally simple, built in the same fashion as that of the color palette, except that it's vertical:

BoxLayout:
    orientation: 'vertical'
    padding: 2
    spacing: 2
    x: 0
    top: root.top
 ...