Skip to content

Instantly share code, notes, and snippets.

@Fak3
Created June 16, 2016 18:10
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 Fak3/2702a360e3662e97d6a68aa26696a17a to your computer and use it in GitHub Desktop.
Save Fak3/2702a360e3662e97d6a68aa26696a17a to your computer and use it in GitHub Desktop.
Issue with kv Builder - <HighLabel> rule does not override defined <Label> properies
from kivy.lang import Builder
from kivy.uix.label import Label
Builder.load_string('''
<HighLabel>:
text: 'height dp(40)'
height: dp(40)
''')
class HighLabel(Label):
pass
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from high_label import HighLabel
Builder.load_string('''
<BoxLayout>:
size: 500, 500
<Label>:
canvas.before:
Color:
rgba: 1,1,1,1
Rectangle:
pos: self.pos
size: self.size
color: 0,0,0,1
size_hint: None, None
height: dp(20)
text: 'height dp(20)'
''')
class MyApp(App):
def build(self):
mainwidget = BoxLayout()
mainwidget.add_widget(HighLabel()) # ! This label will also have height: dp(20) and text: 'height dp(20)'
mainwidget.add_widget(Label())
return mainwidget
if __name__ == '__main__':
MyApp().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment