Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to add scrollbar to listbox in tkinter

from tkinter import *


# Creating the root window
root = Tk()

# Creating a Listbox and
# attaching it to root window
listbox = Listbox(root)

# Adding Listbox to the left
# side of root window
listbox.pack(side = LEFT, fill = BOTH)

# Creating a Scrollbar and
# attaching it to root window
scrollbar = Scrollbar(root)

# Adding Scrollbar to the right
# side of root window
scrollbar.pack(side = RIGHT, fill = BOTH)

# Insert elements into the listbox
for values in range(100):
	listbox.insert(END, values)
	
# Attaching Listbox to Scrollbar
# Since we need to have a vertical
# scroll we use yscrollcommand
listbox.config(yscrollcommand = scrollbar.set)

# setting scrollbar command parameter
# to listbox.yview method its yview because
# we need to have a vertical view
scrollbar.config(command = listbox.yview)

root.mainloop()
Comment

PREVIOUS NEXT
Code Example
Python :: jinja len is undefined 
Python :: list of files in python 
Python :: cv2.adaptiveThreshold() python 
Python :: python how to make a server 
Python :: python endswith list 
Python :: likeliness python 
Python :: python list inversion 
Python :: drop unamed columns in pandas 
Python :: table python 
Python :: python write requests response to text file 
Python :: how to take two integers as input in python 
Python :: python windows take screenshot pil 
Python :: discord.py owner only commands 
Python :: django import timezone 
Python :: python string remove whitespace and newlines 
Python :: number of columns with no missing values 
Python :: gpu training tensorflow 
Python :: wtform custom validator example 
Python :: rerun file after change python 
Python :: actual keystroke python 
Python :: type hint tuple 
Python :: calculate root mean square error python 
Python :: python get pixel color 
Python :: switching versions of python 
Python :: open csv file in python 
Python :: create directory in python 
Python :: python download file from web 
Python :: python check if image is corrupted 
Python :: ModuleNotFoundError: No module named ‘click’ 
Python :: matplotlib show percentage y axis 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =