In order to make all labels' text support markup I use the following kivy-language code at the top of my kivy file:
<Label@Label>:
markup: True
Later on when using:
<SomeWidget>:
Label:
text: '[b]Dog[/b]'
I get a label with the text 'Dog' being bold as expected. Therefor, all my labels have markup set to True as expected.
However, I'm getting the following warning:
[WARNING ] [Factory ] Ignored class "Label" re-declaration. Current - module: kivy.uix.label, cls: None, baseclass: None, filename: None. Ignored - module: None, cls: None, baseclass: Label, filename: /home/Projects/gui/maingui.kv.
Why do I get this warning? Should I be doing something in a different way?
Just use
<Label>:
markup: True
With the @ notation you declare a new dynamic subclass Label derived from Label.
It is useful to create a dynamic class like <MyLabel@Label>: in kv lang, in particular if a reference to the class is not needed later in python, to prevent any clashes that could arise from redefining behaviour (Label is used extensively in other default Widgets, and changing its properties in general might affect the look & feel of other widgets inadvertently).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With