Skip to content
Advertisement

Why my rgb color in Kivymd looks different to real color?

I was changing active color of MDTextFieldRound in Kivymd.

I set theme.cls.primary_palette to Teal, and I want to set active color to accent color or lighter color of Teal.

So I searched on Google and found many posts about teal color’s accent color. And I want to set color to 102,178,178,1 (https://www.color-hex.com/color-palette/4666).

But when I use this code and run:

MDTextFieldRound:
    icon_left: "format-title"
    hint_text: "Set title"
    pos_hint: {"center_x": .5, "center_y": .6}
    width: 500
    size_hint_x: None
    color_active: 102,178,178,1

I can see just white color when active like this. I also tried 0,76,76,1, but then I can see just skyblue color.

Why this happens? And how to use exact color with RGB in kivymd?

I’m using Python 3.8 and Windows 10. Thanks!

Advertisement

Answer

Colors in Kivy are lists of values from 0 to 1. To get those values just divide values that are between 0 and 255 by 255. So you teal becomes 102/255,178/255,178/255,1 or:

color_active: 0.4, 0.698, 0.698, 1
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement