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 Widget
s, and changing its properties in general might affect the look & feel of other widgets inadvertently).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.