Tkinter is a GUI library in python which is easy to read and understand. In Tkinter, multiple selections can be done using the List box widget. Generally, a Listbox displays different items in the form of a list. A list box widget provides one or more selections of items from a list. There are many options available in a Listbox widget that makes the user select multiple options. By assigning the select mode option as multiple, the user can able to select multiple options. If the select mode option is single then only one option can be selected by the user.
The selectmode option of a listbox widget can be single, browse, multiple or extended.
- single – Selects one line of text.
- browse – It is a default option where the user can select one line of text.
- multiple – Selects multiple lines of text without dragging from first line of option to last line.
- extended – User can select and drag adjacent multiple lines of text.
list_box = Listbox(root, options, ....)
Example 1: Python program displaying limited items in the listbox.
From the above multiple selection Listbox, the user can select multiple options. As there are limited items in the Listbox that fit into the prescribed size, the user can able to see all the items. But if there are more items to be displayed to the user then all the items are not visible at once in a Listbox. Hence, attaching a scrollbar to a Listbox is necessary if there are more items to be displayed in a list. This can be done by the
yscrollcommand option(to scroll vertically) in Listbox.
Example 2: Python program displaying List box with attached scroll bar.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Python | Creating a button in tkinter
- Creating Tabbed Widget With Python-Tkinter
- Make Notepad using Tkinter
- Color game using Tkinter in Python
- Python | Message Encode-Decode using Tkinter
- Python | Simple registration form using Tkinter
- Python | Simple GUI calculator using Tkinter
- Python | Distance-time GUI calculator using Tkinter
- Python | Random Password Generator using Tkinter
- Python | Real time currency convertor using Tkinter
- Python | Real time weather detection using Tkinter
- Python | Simple FLAMES game using Tkinter
- Python | Simple calculator using Tkinter
- Tkinter | Adding style to the input text using ttk.Entry widget
- Python | Create a digital clock using Tkinter
- Python | Loan calculator using Tkinter
- Getting screen's height and width using Tkinter | Python
- Python Tkinter | Moving objects using Canvas.move() method
- Python - Compound Interest GUI Calculator using Tkinter
- Python Tkinter | Create different type of lines using Canvas class
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.