Open Arelfox opened 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.
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
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()
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!
Cool cool cool. Best of luck on your next try
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"
MainApp().run()`
Result: (2.0.0)
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:
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