Using Checkboxes In A Kivy App


  • Kivy supports both checkboxes and radio buttons to be used in the Apps.


  • Checkboxes are two state buttons with the states being checked and unchecked.


  • Checkboxes have an accompanying label that describes the purpose of the checkbox.


  • Checkboxes can be grouped together to form radio buttons.


  • The selection of a radio button in a group of radio buttons is mutually exclusive.


  • Only one of the radio buttons can be selected at any point in time.


  • Check boxes are used to convey whether a setting is to be applied or not.


  • Radio buttons are used to convey which setting among multiple settings to be applied.



# uix related

from kivy.uix.widget import Widget

from kivy.uix.label import Label

from kivy.uix.checkbox import CheckBox

from kivy.uix.gridlayout import GridLayout


# Graphics related

from import InstructionGroup

from import Color

from import Rectangle


from import App


from kivy.core.window import Window



# Container class for the app's widgets

class UserInterface(GridLayout):


    def __init__(self, **kwargs):

        super(UserInterface, self).__init__(**kwargs)


        # Add labels and checkbox

        self.cols = 2

        self.add_widget(Label(text='Rotate Mode'))

        self.cb_roateMode = CheckBox(active=True)



        self.lbl_roateMode = Label(text='Rotate Mode is on')



        # Change the color of the background to grey

        blue = InstructionGroup()

        blue.add(Color(1, 1, 1, .3))

        blue.add(Rectangle(pos=self.pos, size=(Window.width, Window.height)))



        # Attach a callback



    # Callback for the checkbox

    def on_roateMode_Active(self, checkboxInstance, isActive):

        if isActive:

            self.lbl_roateMode.text = "Rotate mode is on"


            self.lbl_roateMode.text = "Rotate mode is off"


# App derived from App class

class CheckBoxApp(App):


    def build(self):

        ux = UserInterface()

        return ux


# Run the app

if __name__ == '__main__':




Check boxes in Kivy






Copyright 2018 ©