Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WARNING: Ignored class "Label" re-declaration

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?

like image 740
user Avatar asked Nov 25 '25 04:11

user


1 Answers

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).

like image 169
zeeMonkeez Avatar answered Nov 27 '25 16:11

zeeMonkeez