Window.clearcolor = (1, 1, 0.98, 1)
class SpinnerColor(Widget):
def __init__(self, **kwargs):
super().__init__(**kwargs)
cx = Window.width / 2
self.lbl = Label(text='Color: None', color=(0,0,0,1),pos=(cx - 80, Window.height - 120))
self.add_widget(self.lbl)
self.sp = Spinner(text='Color', values=('Red','Green','Blue'),size_hint=(None, None), width=150, height=40,pos=(cx + 60, Window.height - 120))
self.sp.bind(text=self.on_pick)
self.add_widget(self.sp)
def on_pick(self, inst, val):
cmap = {'Red': (1,0,0,1), 'Green': (0,0.6,0,1), 'Blue': (0,0,1,1)}
self.lbl.text = f'Color: {val}'
self.lbl.color = cmap.get(val, (0,0,0,1))
class SpinnerApp(App):
def build(self):
return SpinnerColor()
if __name__ == '__main__':
SpinnerApp().run()