Skip to content

Instantly share code, notes, and snippets.

@tshirtman
Created June 7, 2020 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tshirtman/089f3fbb63fceceb89e81fb03cc6d33c to your computer and use it in GitHub Desktop.
Save tshirtman/089f3fbb63fceceb89e81fb03cc6d33c to your computer and use it in GitHub Desktop.
showing the usage of - before a property rule
from kivy.app import App
from kivy.lang import Builder
from kivy.factory import Factory
from kivy import properties as P
KV = '''
<CustomLabel@Label>:
font_size: app.font_size1
<CustomLabel2@CustomLabel>:
font_size: app.font_size2
<CustomLabel3@CustomLabel>:
-font_size: app.font_size2
BoxLayout:
orientation: 'vertical'
CustomLabel:
text: 'CustomLabel'
CustomLabel2:
text: 'CustomLabel2'
CustomLabel3:
text: 'CustomLabel3'
Slider:
value: app.font_size1
min: 0
max: 100
step: 1
on_value: app.font_size1 = self.value
Slider:
value: app.font_size2
min: 0
max: 100
step: 1
on_value: app.font_size2 = self.value
'''
class Application(App):
font_size1 = P.NumericProperty(10)
font_size2 = P.NumericProperty(10)
def build(self):
return Builder.load_string(KV)
if __name__ == "__main__":
Application().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment