Last active
August 29, 2015 14:16
-
-
Save kived/a2c68b8383af02d13646 to your computer and use it in GitHub Desktop.
Kivy: square box test
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.8.1') | |
from kivy.app import App | |
from kivy.lang import Builder | |
root = Builder.load_string(''' | |
BoxLayout: | |
orientation: 'vertical' | |
Label: | |
text: 'hello' | |
canvas.before: | |
Color: | |
rgba: 1, 0, 0, 1 | |
Rectangle: | |
pos: self.pos | |
size: self.size | |
FloatLayout: | |
Button: | |
size_hint: None, None | |
pos_hint: {'center': (0.5, 0.5)} | |
aspect: self.parent.width / self.parent.height if self.parent.height else 1 | |
width: self.parent.width if self.aspect < 1 else self.parent.height | |
height: self.parent.width if self.aspect < 1 else self.parent.height | |
text: 'button' | |
Label: | |
text: 'goodbye' | |
canvas.before: | |
Color: | |
rgba: 1, 0, 0, 1 | |
Rectangle: | |
pos: self.pos | |
size: self.size | |
''') | |
class TestApp(App): | |
def build(self): | |
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