Here is an example:
Note the highlighted line.
{'normal': (1,0,1,1), 'down': (1,1,0,1)} [self.state]
This creates a dictionary with 2 keys, normal and down and uses self.state to index into the dict, selecting the color.
from kivy.app import App
from kivy.lang import Builder
kv = """
BoxLayout:
ToggleButton:
text: 'I am a Toggle'
color: {'normal': (1,0,1,1), 'down': (1,1,0,1)} [self.state]
"""
class ColorToggle(App):
def build(self):
return Builder.load_string(kv)
ColorToggle().run()
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/a8ec73e4-839f-40bb-8169-4fc64642ff32o%40googlegroups.com.