Last active
December 22, 2015 00:29
-
-
Save Zen-CODE/6389737 to your computer and use it in GitHub Desktop.
Demo of Stencil behavior
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
from kivy.lang import Builder | |
from kivy.app import App | |
from kivy.uix.label import Label | |
from kivy.uix.floatlayout import FloatLayout | |
Builder.load_string(""" | |
<CustomLabel>: | |
canvas.before: | |
StencilPush | |
Rectangle: | |
pos: 0, 0 | |
size: 200, 200 | |
StencilUse | |
#canvas.after: | |
Color: | |
rgba: 0, 0, 1, 0.5 | |
Rectangle: | |
pos: self.pos | |
size: self.size | |
StencilUnUse | |
StencilPop | |
Color: | |
rgba: 0, 1, 0, 0.5 | |
Rectangle: | |
pos: self.pos | |
size: self.size | |
""") | |
class CustomLabel(Label): | |
pass | |
class TestApp(App): | |
def build(self): | |
root = FloatLayout() | |
lbl = CustomLabel(text="Test") | |
root.add_widget(lbl) | |
return root | |
if __name__ == "__main__": | |
TestApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment