Home > kivy, multitouch, python > Kivy – Label with background

Kivy – Label with background

Kivy is a framework for develop multitouch applications, I started to use pyMT, but pyMT evolved into Kivy.

Adding a background to a label is not possible using the common functions in documentation.

A possible solution by @Mathieu Virbel could be:

class MyLabelWithBackground(Label):
  pass
And put in a kv that you load somewhere:
<MyLabelWithBackground>:
  canvas.before:
    Color:
      rgb: 1, 0, 0 # your color here
    Rectangle:
      pos: self.pos
      size: self.size
Categories: kivy, multitouch, python Tags: , , ,
  1. Marco Heins
    September 21st, 2014 at 05:25 | #1

    Very cool! Can I also pass rgb as parameters to MyLabelWithBackground to have different colored backgrounds without rewriting the whole class?

  2. Marco Heins
    September 21st, 2014 at 05:26 | #2

    Very cool? Can I also pass rgb as parameters to MyLabelWithBackground to have different colored background without rewriting the whole class?

  1. No trackbacks yet.