Skip to content

Instantly share code, notes, and snippets.

@tito
Forked from geojeff/gist:3052621
Created July 5, 2012 09:45
Show Gist options
  • Save tito/3052667 to your computer and use it in GitHub Desktop.
Save tito/3052667 to your computer and use it in GitHub Desktop.
import kivy
kivy.require('1.0.7')
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ListProperty
from kivy.lang import Builder
Builder.load_string('''
<LabelWithBackground>:
canvas.before:
Color:
rgba: self.background_color
Rectangle:
pos: self.pos
size: self.size
''')
class LabelWithBackground(Label):
background_color = ListProperty([1., 0., 0., 1])
class LabelTest(App):
def build(self):
box_layout = BoxLayout()
label_with_background = LabelWithBackground(text='Kivy rulz', font_size=98, pos=(400, 328), background_color=[1., 0., 1., 1])
box_layout.add_widget(label_with_background)
return box_layout
if __name__ in ('__main__', '__android__'):
LabelTest().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment