Last active
August 29, 2015 13:56
-
-
Save brousch/8806515 to your computer and use it in GitHub Desktop.
size_hint bug demo
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.app import App | |
from kivy.lang import Builder | |
from kivy.uix.boxlayout import BoxLayout | |
kv = """ | |
<Test>: | |
orientation: 'horizontal' if root.width > root.height else 'vertical' | |
Button: | |
text: "Button1\\n{}x{}".format(self.width, self.height) | |
size_hint: (None, 1) if root.width > root.height else (1, None) | |
Button: | |
text: "Button2\\n{}x{}".format(self.width, self.height) | |
size_hint: (0.75, 1) if root.width > root.height else (1, 0.75) | |
""" | |
Builder.load_string(kv) | |
class Test(BoxLayout): | |
def __init__(self, **kwargs): | |
super(Test, self).__init__(**kwargs) | |
class TestApp(App): | |
def build(self): | |
return Test() | |
if __name__ == '__main__': | |
TestApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment