Welcome folks today in this post we will be adding checkboxes
inside tkinter using checkbutton
widget in python. All the full source code of the application is shown below.
Get Started
In order to get started you need to make an app.py
file and copy paste the following code
app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
from tkinter import * from tkinter.ttk import * window = Tk() window.title("Welcome to LikeGeeks app") window.geometry('350x200') chk_state = BooleanVar() chk_state.set(True) #set check state chk = Checkbutton(window, text='Apple', var=chk_state) chk.grid(column=0, row=0) chk_state = BooleanVar() chk_state.set(False) #set check state chk2 = Checkbutton(window, text='Mango', var=chk_state) chk2.grid(column=0, row=1) window.mainloop() |
Now if you execute the above python
script by typing the below command
python app.py