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
Advertisements
Categories: kivy, multitouch, python Tags: , , ,
  1. Marco Heins
    September 21, 2014 at 5:25 am

    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 21, 2014 at 5:26 am

    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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: