A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/python/python-tkinter-listbox-widget/ below:

Python Tkinter - ListBox Widget

Python Tkinter - ListBox Widget

Last Updated : 12 Jul, 2025

Tkinter is a GUI toolkit used in python to make user-friendly GUIs.Tkinter is the most commonly used and the most basic GUI framework available in python. Tkinter uses an object-oriented approach to make GUIs. 

Note: For more information, refer to Python GUI – tkinter

ListBox widget

The ListBox widget is used to display different types of items. These items must be of the same type of font and having the same font color. The items must also be of Text type. The user can select one or more items from the given list according to the requirement.

Syntax:

listbox = Listbox(root, bg, fg, bd, height, width, font, ..) 

Optional parameters

Common methods

Example 1: 

Python3
from tkinter import *

# create a root window.
top = Tk()

# create listbox object
listbox = Listbox(top, height = 10, 
                  width = 15, 
                  bg = "grey",
                  activestyle = 'dotbox', 
                  font = "Helvetica",
                  fg = "yellow")

# Define the size of the window.
top.geometry("300x250")  

# Define a label for the list.  
label = Label(top, text = " FOOD ITEMS") 

# insert elements by their
# index and names.
listbox.insert(1, "Nachos")
listbox.insert(2, "Sandwich")
listbox.insert(3, "Burger")
listbox.insert(4, "Pizza")
listbox.insert(5, "Burrito")

# pack the widgets
label.pack()
listbox.pack()


# Display until User 
# exits themselves.
top.mainloop()

Output:

  

Example 2: Let's Delete the elements from the above created listbox 

Python3
# Delete Items from the list
#  by specifying the index.
listbox.delete(2)

Output:



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4