Kivy has the properties background_active
and background_normal
for setting a TextInput
widget's background when it is in focus and when it is not in focus, respectively. However, this sets a background image, and not an rgba
color. There is a background_color
property, but this sets the TextInput
's background color regardless of whether or not it is in focus.
How can I change an TextInput
's background color depending on whether or not it is focused?
Try creating a new TextInput in the KV file
<MyTextInput@TextInput>:
background_color: (1,0,0,1) if self.focus else (0,0,1,1)
This will bind the focus attribute so the color will change according to the focus...