Use the scrollbar with canvax or frame listbox by pack in tkinter of python

Example of use the scrollbar with help of Canvas or Frame in listbox of tkinter in python

# import required modules


from tkinter import *

tkWindow = Tk()  
tkWindow.geometry('500x500')  
tkWindow.title('Test scrollbar with listbox')

frame = Frame(tkWindow)
canvas = Canvas(frame)
               
SelectuserLabel = Label(canvas, text="Select the Schema").pack()
test = Listbox(canvas, 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)
scrollbar = Scrollbar(frame)

scrollbar.config(command = test.yview)
scrollbar.pack(side = RIGHT, fill= Y)
test.pack()
canvas.pack()
frame.pack()
tkWindow.mainloop()

Ouput:

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 )

Google photo

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

Twitter picture

You are commenting using your Twitter 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.