Last active
July 7, 2016 14:51
-
-
Save Alan-FGR/706eb76ee887fbdde8d3fa9e8267fb9c to your computer and use it in GitHub Desktop.
If you uncomment the code on line 15, it works properly
This file contains hidden or 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.app import Builder | |
| from kivy.uix.stacklayout import StackLayout | |
| from kivy.uix.label import Label | |
| from kivy.uix.button import Button | |
| from kivy.properties import NumericProperty | |
| Builder.load_string(""" | |
| <MyLabel>: | |
| size_hint: 1, None | |
| font_size: app.some_multiplier*10 | |
| <MySubLabel>: | |
| font_size: 10 # or app.some_multiplier | |
| """) | |
| class MyLabel(Label): | |
| pass | |
| class MySubLabel(MyLabel): | |
| pass | |
| class Test(App): | |
| some_multiplier = NumericProperty(1.0) | |
| def build(self): | |
| root_layout = StackLayout() | |
| root_layout.add_widget(MyLabel(text="MYLABEL")) | |
| root_layout.add_widget(MySubLabel(text="MYSUBLABEL")) | |
| property_change_button = Button(text="Change Multiplier", size_hint_y=None) | |
| property_change_button.bind(on_press=self.change_multiplier) | |
| root_layout.add_widget(property_change_button) | |
| return root_layout | |
| def change_multiplier(self, *args): | |
| self.some_multiplier += 0.5 | |
| if __name__ == "__main__": | |
| Test().run() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While using 'or' is a cool trick, kivy should always respect the user defined rules no matter what.