Skip to content
Advertisement

Using hex color code from py file in kv file

I am making this program that deals with a lot of colors and it gives the user the freedom to change many of them. In one part of my program I use markup for one of my labels and and I realized something about the ‘color’ tag.

When my program starts I want my label to follow the theme but I get this warning when trying to set the color to the theme and it does not show the color correctly:

JavaScript

I don’t know how to have the hex code that is inside my py file work in the kv file. How can I solve this? My Code:

JavaScript

Advertisement

Answer

loadString interprets the entire value of text as a string when enclosed by quotes. In order to make it interpret app.hex_txt_color as a variable you can concatenate the variable to the string. As an example:

JavaScript

You can use python code like:

JavaScript
Advertisement