Search code examples
pythonkivy-language

ValueError: Button.background_down accept only str


I am getting the ValueError: Button.background_down accept only str error when I launch my python kivy app, the issue resides in the .kv file. The program complain about this line: background_down: hex('#DCDCDC'). I know what the error implies, I just don't know how to fix it. I have tried passing in the rgba value (for the sake of trying every way), but it didn't work.

I appreciate any response, cheers!


Solution

  • You can bind button behavior to a background_color:

    in kv lang:

    Button:
        background_color: (1,0,1,1) if self.state == "normal" else (0,1,0,1)
    

    (0,1,0,1) is the color when pressed, you can also do that color first and use if self.state == "down" :)