kivymd / KivyMD

KivyMD is a collection of Material Design compliant widgets for use with Kivy, a framework for cross-platform, touch-enabled graphical applications. https://youtube.com/c/KivyMD https://twitter.com/KivyMD https://habr.com/ru/users/kivymd https://stackoverflow.com/tags/kivymd
https://kivymd.readthedocs.io
MIT License
2.25k stars 674 forks source link

KivyMD 2.0.0 Screen Background is Black (and more) #1740

Open Arelfox opened 2 months ago

Arelfox commented 2 months ago

Software Versions

Whenever I use specifically version 2.0.0 of kivymd, the background screen is black. This does not occur in kivymd version 1.2.0.

Code: (2.0.0) `from kivymd.app import MDApp from kivymd.uix.screen import MDScreen from kivymd.uix.button import MDButton, MDButtonText

class MainApp(MDApp): def build(self): self.theme_cls.theme_style = "Light" self.theme_cls.primary_palette = "Beige"

    return (
        MDScreen(
            MDButton(
                MDButtonText(
                    text="Hello, World",
                ),
                pos_hint={"center_x": 0.5, "center_y": 0.5},
            )
        )
    )

MainApp().run()`

Result: (2.0.0) image

i think at one point it was working fine with more complete code. at first i thought it was my code but its clear that it doesn't work with any example code. it also isn't dependent on if im using a .kv file or not also its more than just the black screen, if i use a canvas to add a custom colored background:

canvas.before:
        Color:
            rgba: 232, 220, 202, 1
        Rectangle:
            pos:self.pos
            size:self.size

it is always white on top of that, textinput features like hint text and icons do not show up, and some button's icons dont appear. might be an issue with installing the package but i have tried reinstalling, will try deleting the entire venv and retry it

Killjoy99 commented 2 months ago
return (
    MDScreen(
        MDButton(
            MDButtonText(
                text="Hello, World",
            ),
            pos_hint={"center_x": 0.5, "center_y": 0.5},
            md_bg_color=app.theme_cls.backgroundColor,
        )
    )
)

You need that one line for things to work as expected. This sets the background color as you set it in your build method. You do the same in a KV file as well.

Arelfox commented 2 months ago

Doesn't work, self.themecls.backgroundColor seems to do nothing for the background in my testing It does however change the individual buttons/labels/etc. colors

Killjoy99 commented 1 month ago

Apologies, Here is a working code snippet i Just tested. I hope it works for you

from kivymd.app import MDApp from kivymd.uix.button import MDButton, MDButtonText from kivymd.uix.screen import MDScreen

class MainApp(MDApp): def build(self): self.theme_cls.theme_style = "Light" return MDScreen( MDButton( MDButtonText( text="Hello, World", ), pos_hint={"center_x": 0.5, "center_y": 0.5}, ), md_bg_color=self.theme_cls.backgroundColor, )

MainApp().run()

Arelfox commented 1 month ago

Its fine, I switched back to KivyMD=1.2.0, I dont want to spend too much time figuring out why only my installation of kivymd 2 was broken. Thanks for your help though!

Killjoy99 commented 1 month ago

Cool cool cool. Best of luck on your next try