Code from the documentation KivyMD:
from kivy.lang import Builder
from kivy.uix.floatlayout import FloatLayout
from kivymd.app import MDApp
from kivymd.uix.tab import MDTabsBase
KV = '''
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "Example Tabs"
MDTabs:
id: tabs
on_tab_switch: app.on_tab_switch(*args)
<Tab>:
MDLabel:
id: label
text: "Tab 0"
halign: "center"
'''
class Tab(FloatLayout, MDTabsBase):
'''Class implementing content for a tab.'''
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
def on_start(self):
for i in range(20):
self.root.ids.tabs.add_widget(Tab(text=f"Tab {i}"))
def on_tab_switch(
self, instance_tabs, instance_tab, instance_tab_label, tab_text
):
'''Called when switching tabs.
:type instance_tabs: <kivymd.uix.tab.MDTabs object>;
:param instance_tab: <__main__.Tab object>;
:param instance_tab_label: <kivymd.uix.tab.MDTabsLabel object>;
:param tab_text: text or name icon of tab;
'''
instance_tab.ids.label.text = tab_text
Example().run()
Error:
Traceback (most recent call last):
File "kivy\properties.pyx", line 2023, in kivy.properties.ColorProperty.convert
File "kivy\properties.pyx", line 2041, in kivy.properties.ColorProperty.parse_list
ValueError: Invalid value for color (got [])
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\lolo\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\lang\builder.py", line 701, in _apply_rule
setattr(widget_set, key, value)
File "kivy\weakproxy.pyx", line 35, in kivy.weakproxy.WeakProxy.__setattr__
File "kivy\properties.pyx", line 498, in kivy.properties.Property.__set__
File "kivy\properties.pyx", line 527, in kivy.properties.Property.set
File "kivy\properties.pyx", line 2025, in kivy.properties.ColorProperty.convert
ValueError: MDTabsLabel.color has an invalid format (got [])
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\lolo\PycharmProjects\FindWord\FindWord.py", line 54, in <module>
Example().run()
File "C:\Users\lolo\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\app.py", line 949, in run
self._run_prepare()
File "C:\Users\lolo\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\app.py", line 944, in _run_prepare
self.dispatch('on_start')
File "kivy\_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
File "C:\Users\lolo\PycharmProjects\FindWord\FindWord.py", line 38, in on_start
self.root.ids.tabs.add_widget(Tab(text=f"Tab {i}"))
File "C:\Users\lolo\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\uix\floatlayout.py", line 65, in __init__
super(FloatLayout, self).__init__(**kwargs)
File "C:\Users\lolo\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\uix\layout.py", line 76, in __init__
super(Layout, self).__init__(**kwargs)
File "C:\Users\lolo\AppData\Local\Programs\Python\Python39\lib\site-packages\kivymd\uix\tab.py", line 374, in __init__
self.tab_label = MDTabsLabel(tab=self)
File "C:\Users\lolo\AppData\Local\Programs\Python\Python39\lib\site-packages\kivymd\uix\tab.py", line 328, in __init__
super().__init__(**kwargs)
File "C:\Users\lolo\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\uix\behaviors\togglebutton.py", line 84, in __init__
super(ToggleButtonBehavior, self).__init__(**kwargs)
File "C:\Users\lolo\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\uix\behaviors\button.py", line 121, in __init__
super(ButtonBehavior, self).__init__(**kwargs)
File "C:\Users\lolo\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\uix\label.py", line 318, in __init__
super(Label, self).__init__(**kwargs)
File "C:\Users\lolo\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\uix\widget.py", line 359, in __init__
self.apply_class_lang_rules(
File "C:\Users\lolo\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\uix\widget.py", line 463, in apply_class_lang_rules
Builder.apply(
File "C:\Users\lolo\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\lang\builder.py", line 541, in apply
self._apply_rule(
File "C:\Users\lolo\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\lang\builder.py", line 710, in _apply_rule
raise BuilderException(rule.ctx, rule.line,
kivy.lang.builder.BuilderException: Parser: File "<inline>", line 19:
...
17: )
18: color:
>> 19: self.text_color_active if self.state == 'down' else self.text_color_normal
20: on_x: self._trigger_update_tab_indicator()
21: on_width: self._trigger_update_tab_indicator()
...
ValueError: MDTabsLabel.color has an invalid format (got [])
File "C:\Users\lolo\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\lang\builder.py", line 701, in _apply_rule
setattr(widget_set, key, value)
File "kivy\weakproxy.pyx", line 35, in kivy.weakproxy.WeakProxy.__setattr__
File "kivy\properties.pyx", line 498, in kivy.properties.Property.__set__
File "kivy\properties.pyx", line 527, in kivy.properties.Property.set
File "kivy\properties.pyx", line 2025, in kivy.properties.ColorProperty.convert
This is an error of under-installed packages, I have already encountered it. then I downloaded some repository, and everything worked. I recently decided to update kivy, and the error occurred again.