Created
June 16, 2016 18:10
-
-
Save Fak3/2702a360e3662e97d6a68aa26696a17a to your computer and use it in GitHub Desktop.
Issue with kv Builder - <HighLabel> rule does not override defined <Label> properies
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.lang import Builder | |
from kivy.uix.label import Label | |
Builder.load_string(''' | |
<HighLabel>: | |
text: 'height dp(40)' | |
height: dp(40) | |
''') | |
class HighLabel(Label): | |
pass |
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 | |
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