KivyMD icon indicating copy to clipboard operation
KivyMD copied to clipboard

ValueError: None is not allowed for MDSnackbarActionButtonText.color when is set the theme_text_color.

Open RicardoDazzling opened this issue 7 months ago • 3 comments

Description of the Bug

Hello everyone! I'm with a issue with the theme text color. I want to create a snackbar and give to a button the default error text color. But when I change the theme_text_color to "Error" it give-me a None Value Exception. I think that is because in the new update, the default theme text colors aren't implemented... It will be implemented in the future?

Code and Logs

It can be repliqued with a simple creation of a snackbar with the action button with the property theme_text_color. Like this:

from kivy.metrics import dp
from kivymd.app import MDApp
from kivymd.uix.snackbar import MDSnackbar, MDSnackbarSupportingText, MDSnackbarButtonContainer, MDSnackbarActionButton, \
    MDSnackbarActionButtonText


class MainApp(MDApp):
    def build(self):
        pass

    def on_start(self):
        MDSnackbar(
            MDSnackbarSupportingText(
                text="Single-line snackbar with action",
            ),
            MDSnackbarButtonContainer(
                MDSnackbarActionButton(
                    MDSnackbarActionButtonText(
                        theme_text_color="Error",
                        text="Action button"
                    ),
                ),
                pos_hint={"center_y": 0.5}
            ),
            y=dp(24),
            orientation="horizontal",
            pos_hint={"center_x": 0.5},
            size_hint_x=0.5,
            auto_dismiss=False
        ).open()


if __name__ == '__main__':
    app = MainApp()
    app.run()
    

Log:

[INFO   ] [Logger      ] Record log in .kivy\logs\kivy_24-07-02_0.txt
[INFO   ] [deps        ] Successfully imported "kivy_deps.angle" 0.4.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.glew" 0.3.1
[INFO   ] [deps        ] Successfully imported "kivy_deps.sdl2" 0.7.0
[INFO   ] [Kivy        ] v2.3.0
[INFO   ] [Kivy        ] Installed at "...\.env\Lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "D:\DR\Python\.envs\agendamd\Scripts\python.exe"
[INFO   ] [Logger      ] Purge log fired. Processing...
[INFO   ] [Logger      ] Purge finished!
[INFO   ] [KivyMD      ] 2.0.1.dev0, git-Unknown, 2024-05-08 (installed at "...\.env\Lib\site-packages\kivymd\__init__.py")
[INFO   ] [Factory     ] 195 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL" graphics system
[INFO   ] [GL          ] GLEW initialization succeeded
[INFO   ] [GL          ] Backend used <glew>
[INFO   ] [GL          ] OpenGL version <b'4.6.0 - Build 27.20.100.7988'>
[INFO   ] [GL          ] OpenGL vendor <b'Intel'>
[INFO   ] [GL          ] OpenGL renderer <b'Intel(R) HD Graphics 630'>
[INFO   ] [GL          ] OpenGL parsed version: 4, 6
[INFO   ] [GL          ] Shading version <b'4.60 - Build 27.20.100.7988'>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <32>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO   ] [Clipboard   ] Provider: winctypes
[INFO   ] [GL          ] NPOT texture support is available
 Traceback (most recent call last):
   File "...\.env\Lib\site-packages\kivy\lang\builder.py", line 705, in _apply_rule
     setattr(widget_set, key, value)
   File "kivy\\weakproxy.pyx", line 35, in kivy.weakproxy.WeakProxy.__setattr__
   File "kivy\\properties.pyx", line 520, in kivy.properties.Property.__set__
   File "kivy\\properties.pyx", line 564, in kivy.properties.Property.set
   File "kivy\\properties.pyx", line 555, in kivy.properties.Property.set
   File "kivy\\properties.pyx", line 593, in kivy.properties.Property.check
 ValueError: None is not allowed for MDSnackbarActionButtonText.color
 
 During handling of the above exception, another exception occurred:
 
 Traceback (most recent call last):
   File "snackbar.py", line 35, in <module>
     app.run()
   File "...\.env\Lib\site-packages\kivy\app.py", line 955, in run
     self._run_prepare()
   File "...\.env\Lib\site-packages\kivymd\app.py", line 142, in _run_prepare
     super()._run_prepare()
   File "...\.env\Lib\site-packages\kivy\app.py", line 950, in _run_prepare
     self.dispatch('on_start')
   File "kivy\\_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
   File "snackbar.py", line 18, in on_start
     MDSnackbarActionButtonText(
   File "...\.env\Lib\site-packages\kivymd\uix\label\label.py", line 739, in __init__
     super().__init__(*args, **kwargs)
   File "...\.env\Lib\site-packages\kivymd\uix\behaviors\declarative_behavior.py", line 311, in __init__
     super().__init__(**kwargs)
   File "...\.env\Lib\site-packages\kivymd\theming.py", line 977, in __init__
     super().__init__(**kwargs)
   File "...\.env\Lib\site-packages\kivymd\uix\behaviors\backgroundcolor_behavior.py", line 164, in __init__
     super().__init__(**kwarg)
   File "...\.env\Lib\site-packages\kivy\uix\label.py", line 319, in __init__
     super(Label, self).__init__(**kwargs)
   File "...\.env\Lib\site-packages\kivy\uix\widget.py", line 366, in __init__
     self.apply_class_lang_rules(
   File "...\.env\Lib\site-packages\kivy\uix\widget.py", line 470, in apply_class_lang_rules
     Builder.apply(
   File "...\.env\Lib\site-packages\kivy\lang\builder.py", line 545, in apply
     self._apply_rule(
   File "...\.env\Lib\site-packages\kivy\lang\builder.py", line 714, in _apply_rule
     raise BuilderException(rule.ctx, rule.line,
 kivy.lang.builder.BuilderException: Parser: File "<inline>", line 76:
 ...
      74:    markup: True
      75:    color:
 >>   76:        self.theme_cls.inversePrimaryColor \
      77:        if self.theme_text_color == "Primary" else \
      78:        self.text_color
 ...
 ValueError: None is not allowed for MDSnackbarActionButtonText.color
   File "...\.env\Lib\site-packages\kivy\lang\builder.py", line 705, in _apply_rule
     setattr(widget_set, key, value)
   File "kivy\\weakproxy.pyx", line 35, in kivy.weakproxy.WeakProxy.__setattr__
   File "kivy\\properties.pyx", line 520, in kivy.properties.Property.__set__
   File "kivy\\properties.pyx", line 564, in kivy.properties.Property.set
   File "kivy\\properties.pyx", line 555, in kivy.properties.Property.set
   File "kivy\\properties.pyx", line 593, in kivy.properties.Property.check
 

Process finished with exit code 1

Versions

  • OS: Windows 10
  • Python: 3.12
  • Kivy: 2.3.0
  • KivyMD: master

RicardoDazzling avatar Jun 30 '24 16:06 RicardoDazzling