Adding scrollbar with listbox as grid tkinter of python

For increase height in grid placement of scrollbar in python

Need to use the sticky=’ns’ for increase the height of scrollbar in python grid placement

Example: scrollbar.grid(row=0,column=2,sticky=’ns’)

# import required modules
from tkinter import *

tkWindow = Tk()  
tkWindow.geometry('500x500')  
tkWindow.title('Example Utility')
              
scrollbar = Scrollbar(tkWindow,orient="vertical")
               
SelectuserLabel = Label(tkWindow, text="Select").grid(row=0,column=0)
test = Listbox(tkWindow, width=20, heigh=5, font=("Helvetica", 14))
test.insert(END,1)
test.insert(END,2)
test.insert(END,3)
test.insert(END,4)
test.insert(END,5)
test.insert(END,6)
test.insert(END,7)
test.insert(END,8)
test.grid(row=0,column=1)
scrollbar.config(command = test.yview)
scrollbar.grid(row=0,column=2,sticky='ns')

tkWindow.mainloop()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.