Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Arelfox opened this issue Sep 20, 2024 · 5 comments
Open

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

Arelfox opened this issue Sep 20, 2024 · 5 comments

Comments

@Arelfox
Copy link

Arelfox commented Sep 20, 2024

Software Versions

  • Python: 3.10
  • OS: Windows 11
  • Kivy: 2.3.0
  • Kivy installation method: pip
  • Kivymd: 2.0.0
  • Kivymd installation method: github instructions on official docs

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
Copy link

Killjoy99 commented Sep 22, 2024

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
Copy link
Author

Arelfox commented Sep 23, 2024

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
Copy link

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
Copy link
Author

Arelfox commented Sep 25, 2024

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
Copy link

Cool cool cool.
Best of luck on your next try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants