
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python Checkbox widget in Kivy?
Kivy is an open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps. It is used to develop the Android application, as well as Desktops applications. In this article we will see how to use the GridLayout and CheckBox.
After importing the relevant modules, we create a grid layout with 2 columns. One to hold the label and another to hold the checkboxes.
Example
import kivy from kivy.app import App from kivy.uix.widget import Widget from kivy.uix.label import Label from kivy.uix.checkbox import CheckBox from kivy.uix.gridlayout import GridLayout # Container class for the app's widgets class chk_box(GridLayout): def __init__(self, **kwargs): super(chk_box, self).__init__(**kwargs) # Grid layout for 2 columns self.cols = 2 # Add checkbox, widget and labels self.add_widget(Label(text='10 AM to 11 AM' )) self.active = CheckBox(active=True) self.add_widget(self.active) self.add_widget(Label(text='3 PM to 4 PM')) self.active = CheckBox(active=False) self.add_widget(self.active) class CheckBoxApp(App): def build(self): return chk_box() CheckBoxApp().run()
Output
Running the above code gives us the following result −
- Related Articles
- Python - BoxLayout widget in Kivy
- How to add drag behavior in kivy widget?
- Python - AnchorLayout in Kivy
- Python Float Layout in Kivy?
- Python - Button Action in Kivy
- Python - Window size Adjustment in Kivy
- Python - Working with buttons in Kivy
- Python - Add Label to kivy window
- How to add custom fonts in Kivy - Python?
- Progressbar widget in Python Tkinter
- Combobox Widget in Python Tkinter
- Introduction to Kivy; A Cross-platform Python Framework
- Passing Checkbox Data to CGI Program in Python
- Animated Floating Action Button in kivy
- How to add Matplotlib graph in Kivy?

Advertisements