How to change button color in kivyMD

285 views
Skip to first unread message

Remo G

unread,
Aug 7, 2020, 12:26:12 AM8/7/20
to Kivy users support
i've a 

'MDFillRoundFlatButton' in my application but somehow i cannot change its color.

Robert Flatt

unread,
Aug 7, 2020, 2:41:53 AM8/7/20
to Kivy users support
Not exactly the same case, but a snippet from some code of mine adjusting the shade of MDRoundFlatButton.

The whole point of MD is it is a set of design rules, so you can't do what ever you want because of the rules :(
  
        b = MDRoundFlatButton()
        c
= MDApp.get_running_app().theme_cls.primary_palette
        h
= MDApp.get_running_app().theme_cls.primary_hue
        b
.md_bg_color = get_color_from_hex(MDcolors[c][str(int(h)+100)])
        b
.text_color = MDApp.get_running_app().theme_cls.text_color

mate...@gmail.com

unread,
Aug 21, 2020, 9:31:50 AM8/21/20
to Kivy users support
I'm sorry but I don't get what MDApp means, I'm using KivyMD and I want to change  the button color using its id from python at the end of a function. Should I import sth before writing the variables "c" and "h"?

Robert Flatt

unread,
Aug 21, 2020, 1:25:29 PM8/21/20
to Kivy users support
MDApp is the root class of any KivyMD app. Just search in your app and you will find it imported near the top and used closer to the bottom.
Reply all
Reply to author
Forward
0 new messages