Reputation: 773
I'm trying to set the background color of the Spinner, if disabled.
Here is what I tried in my kv-file:
<MySpinner@Spinner>:
background_normal: ''
background_disabled_normal: ''
disabled_color: (0, 0, 0, 1)
color: (0, 0, 0, 1)
background_disabled_color: (1,1,1,1)
background_color: (0.62,0.67,0.72,1)
Obviously the background_disabled_color
is not the right parameter. But what should I use instead?
Upvotes: 1
Views: 910
Reputation: 12189
It inherits from Button
, therefore if it's not in the spinner.py
file, it'll be in button.py
You can see that Button
uses images for the background and with background_color
it's only tinted, yet there's no background_disabled_color
(afaik). The background works like this - you set background_color
and if the widget is disabled, it tints the default background image for disabled (which is little bit darker):
Button:
text: 'jump'
disabled: True
# background_disabled_normal: '' # allow to see the behavior w/o default disabled bg
background_color: (1,0,0,1)
To achieve another color for disabled widget than the default background_color
you need to change the background_color
when the Button
is disabled (in your case Spinner
):
from kivy.lang import Builder
from kivy.base import runTouchApp
from kivy.uix.boxlayout import BoxLayout
Builder.load_string('''
<Test>:
Spinner:
id: special
values: [str(i) for i in range(10)]
size_hint_y: None
text: 'jump'
disabled: True
#background_disabled_normal: ''
background_color: (1,0,0,1) if not self.disabled else (0,1,0,1)
Button:
on_release: special.disabled = not special.disabled
''')
class Test(BoxLayout): pass
runTouchApp(Test())
Note that this won't work for the DropDown
-like children, because those use different class, so to change them you'll need to change properties of that class.
Upvotes: 1