Kivy Tutorials
About Lesson

In this Kivy Tutorial we are going to talk about Kivy CheckBox, Kivy CheckBox is a specific two-state button that can be either checked or unchecked. If the CheckBox is in a Group, it becomes a Radio button. As with the ToggleButton , only one Radio button at a time can be selected when the CheckBox.group is set.

 

There are two ways that you can create checkbox in kivy, the first way is that you can create checkbox using the kivy.uix.checkbox module, and the second way is using the kivy design language, so first let’s just do the first way. also iam going to show you how to create callbacks for the kivy checkbox.

 

 

First of all create a Python file and add this code in the file.

In the above code you can see that we have created a class that extends from GridLayout, also we have added column number for the GridLayout , and we created our checkboxes and labels in that class, also you can see that i have binded the event with the checkbox like this.

 

 

And this is my method that i have already binded with the checkbox.

 

 

This method returns the window content. in this case  our CheckBoxClass class.

 

 

 

Run the complete code and this is the result.

Kivy Tutorial - Kivy CheckBox
Kivy Tutorial – Kivy CheckBox

 

 

 

Creating Kivy CheckBox with KV Language 

 Let’s create our checkbox using kivy design language, first of all this is our Python code.

In the code we have a class that extends from GridLayout, and we have added the checkbox callback in that class.

 

 

And this is our Kivy file, make sure that your Kivy file name should be checkboxex.kv, because our main class is CheckBoxEx.

 

 

 

 

Run the code and this is the result.

Kivy CheckBox
Kivy CheckBox