Tkinter is the standard GUI library for Python. Tkinter in Python comes with a lot of good widgets. Widgets are standard GUI elements, and the Listbox, Scrollbar will also come under this Widgets.
Note: For more information, refer to Python GUI – tkinter
Listbox
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, ..)

Scrollbar
The scrollbar widget is used to scroll down the content. We can also create the horizontal scrollbars to the Entry widget.
Syntax:
The syntax to use the Scrollbar widget is given below.
w = Scrollbar(master, options)
Parameters:
- master: This parameter is used to represents the parent window.
- options: There are many options which are available and they can be used as key-value pairs separated by commas.

Adding Scrollbar to ListBox
To do this we need to attach the scrollbar to Listbox, and to attach we use a function listbox.config()
and set its command parameter to the scrollbar’s set method then set the scrollbar’s command parameter to point a method that would be called when the scroll bar position is changed
from tkinter import *
root = Tk()
listbox = Listbox(root)
listbox.pack(side = LEFT, fill = BOTH)
scrollbar = Scrollbar(root)
scrollbar.pack(side = RIGHT, fill = BOTH)
for values in range ( 100 ):
listbox.insert(END, values)
listbox.config(yscrollcommand = scrollbar. set )
scrollbar.config(command = listbox.yview)
root.mainloop()
|
Output

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
26 Mar, 2020
Like Article
Save Article