Python Kivy Creating ToggleButton

This is our tenth article in Python Kivy, in this article we are going to learn Creating ToggleButton in Kivy, the ToggleButton widget acts like a checkbox. When you touch or click it, the state toggles between ‘normal’ and ‘down’ (as opposed to a Button that is only ‘down’ as long as it is pressed). toggle buttons can also be grouped to make radio buttons – only one button in a group can be in a ‘down’ state. the group name can be a string or any other hashable Python object.

 

 

Kivy Crash Course Articles

1: Kivy Crash Course Introduction & Installation

2: Introduction to Kv Design Language 

3: Kivy Button with Callbacks

4: Kivy Layout Management 

5: How to Create CheckBox in Kivy

6: Kivy Image And AsyncImage Example

7: How to Create Slider in Python Kivy

8: How to Create TextInput in Python Kivy

9: How to Play Video in Python Kivy

 

 

 

 

Also you can watch the complete video for this article

 

 

 

 

OK so first of all create a python file like this , and add these codes in that file. basically at the top we have created a class that extends from GridLayout, because we are going to add our toggle button in the grid layout. after that we have created our main class that extends from the App class, and we return our MyToggleButton class in their.

 

 

 

 

Now this is our .kv file, and i have name the file togglewindow.kv, make sure that this name should be similar to the main  class name, in my case it is ToggleWindow class.

 

 

 

 

 

So now if you run the code this will be the result.

Python Kivy Creating ToggleButton
Python Kivy Creating ToggleButton

 

 

 

Subscribe and Get Free Video Courses & Articles in your Email

 

Codeloop
Share via
Copy link
Powered by Social Snap
×