Skip to content
Advertisement

Display Kivy Color Wheel only

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:

<ColourScreen>:
    Label:
        text: 'Please Choose the colour for Team 1'

    ColorPicker:

and my .py file:

class ColourScreen(Screen):
    pass

class TheApp(App):

    def build(self):
        sm = ScreenManager()
        sm.add_widget(ColourScreen(name='colour_screen'))
        sm.current ='colour_screen'


        return sm

def main():
    Builder.load_file('menu.kv')
    app = TheApp()
    app.run()

if __name__ == '__main__':
    main()

Could anybody help? Thanks in advance

Advertisement

Answer

Try using ColorWheel instead. You can use it in the kv as:

<ColourScreen>:
    Label:
        text: 'Please Choose the colour for Team 1'

    ColorWheel:
        on_color: root.color_selected(self.color)

And the color_selected() method:

class ColourScreen(Screen):
    def color_selected(self, color):
        print('got color', color)
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement