I am writing an app that has a need for the Kivy Color Wheel (https://kivy.org/doc/stable/api-kivy.uix.colorpicker.html) to choose a color value to assign to different users. However, I intend for it to be used on a phone screen, and as such I do not need the various sliders and color codes that make up the second half of the widget – simply tapping the desired colour is sufficient. I know that there is a question very similar to this that is answered, however this does not account for the .kv language that I am using in my program.
This is my .kv code:
JavaScript
x
6
1
<ColourScreen>:
2
Label:
3
text: 'Please Choose the colour for Team 1'
4
5
ColorPicker:
6
and my .py file:
JavaScript
1
21
21
1
class ColourScreen(Screen):
2
pass
3
4
class TheApp(App):
5
6
def build(self):
7
sm = ScreenManager()
8
sm.add_widget(ColourScreen(name='colour_screen'))
9
sm.current ='colour_screen'
10
11
12
return sm
13
14
def main():
15
Builder.load_file('menu.kv')
16
app = TheApp()
17
app.run()
18
19
if __name__ == '__main__':
20
main()
21
Could anybody help? Thanks in advance
Advertisement
Answer
Try using ColorWheel
instead. You can use it in the kv
as:
JavaScript
1
7
1
<ColourScreen>:
2
Label:
3
text: 'Please Choose the colour for Team 1'
4
5
ColorWheel:
6
on_color: root.color_selected(self.color)
7
And the color_selected()
method:
JavaScript
1
4
1
class ColourScreen(Screen):
2
def color_selected(self, color):
3
print('got color', color)
4