Scrollbar In Python Tkinter Toplevel() Shows Up But Does Not Scroll
I have looked through all the answered questions available here but to no avail. I'm working on Mac OS X High Sierra and my Scrollbar widget shows up but doesn't scroll the window,
Solution 1:
There is nothing inside scrollFrame
.
The labels are packed in popup
, not in scrollCanvas
The scrollCanvas.config(scrollregion=scrollCanvas.bbox('all'))
doesn't seem to do the job, not clear as to why.
Here is an example that works for Python 3.6.5 on windows 10:
from tkinter import *
root = Tk()
root.geometry('200x200')
root.resizable(False, False)
vertScrollbar = Scrollbar(root, orient='vertical')
vertScrollbar.pack(side='right', fill='y')
scrollCanvas = Canvas(root, width='400', height='500',
scrollregion=(0, 0, 400, 500),
yscrollcommand=vertScrollbar.set)
vertScrollbar.config(command=scrollCanvas.yview)
scrollCanvas.pack(side='top', fill='both')
img = PhotoImage(file='test.gif')
scrollCanvas.create_image(2, 2, anchor='nw', image = img)
root.mainloop()
Post a Comment for "Scrollbar In Python Tkinter Toplevel() Shows Up But Does Not Scroll"