-
-
Save tito/3052667 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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