How to create multiple Selection Checkboxes in Tkinter Python
In this tutorial, we will learn about multiple selection checkboxes in Tkinter using Python. Tkinter is an open-source library in Python that is used for Graphical User Interface(GUI). Using this library one can create a lot like that are required for the user interface. Tkinter also provides the feature of CheckBoxes which we are going to learn here. To create multiple selection checkboxes we will use radio buttons. Generally to select multiple checkboxes we will create a list. In this list, we use multiple select checkboxes we need to select more than one item. To do this we will set the checkbox as multiple this supports selecting more than one item from the list.
We will discuss more using examples.Python: Radio buttons in Tkinter This link will help to get more understanding about Tkinter.
Python code for Multiple checkboxes using Tkinter in Python
#Importing all required libraries from tkinter import * #Creating a window win = Tk() win.geometry("150x150") #Here we select multiple mode to select more than one option #creating a list of items that we want to display on the window opt = Listbox(win,selectmode="multiple") lis=["Tkinter","pandas","opencv","numpy","tensorflow","graph-tool","mlpack"] #Now we will add this into window as it would expand accordingly in both axis opt.pack(expand=YES,fill="both") #insering each items into options this will add into list that get displayed for i in lis: opt.insert(END,i) #keeping the window into main loop this will keep window displayed win.mainloop()
Here I have selected “Tkinter”, “Pandas” and “Numpy”. You can also deselect those by clicking again on the selected item in the list. Here you can see the elements that I have selected in the output image.
Here in this image, you can see the multiple select checkboxes. You can also try a lot using these.