Search on blog:

Tkinter: How to display Listbox with Scrollbar

It adds Listbox on left side and Scrollbar on right side.

Scrollbar uses command=listbox.yview to move Listbox content when Scrollbar is moved.

Listbox uses yscrollcommand=scrollbar.set to move Scrollbar when element in Listbox is added or removed or content is moved by key or mouse wheel.

import tkinter as tk

root = tk.Tk()

listbox = tk.Listbox(root)
listbox.grid(row=0, column=0, sticky="news")

scrollbar = tk.Scrollbar(root, orient='vertical', command=listbox.yview)
scrollbar.grid(row=0, column=1, sticky='ns')


# add some values to listbox for scrolling
for i in range(50):
    listbox.insert('end', str(i))

If you like it
Buy a Coffee