I built scrollable canvas before, but now I have to fill one of them with buttons, and I don't know why the scrollbar is inactive... maybe the problem is that the canvas contains buttons?
It's strange that it is inactive since the canvas and the scrollbar seem to be correctly connected by vscrollbar.set
and cv.yview
...
from Tkinter import *
def main():
root = Tk()
root.geometry("%dx%d+0+0" % (1800,1000))
auxframe=Frame(root)
auxframe.pack(fill=BOTH, expand=YES)
cv = Canvas(auxframe, scrollregion=(0,0,8000,8000))
vscrollbar = Scrollbar(auxframe, orient=VERTICAL)
vscrollbar.pack(fill=Y, side=RIGHT)
vscrollbar.config(command=cv.yview)
cv.config(yscrollcommand=vscrollbar.set)
cv.pack(side=LEFT, fill=BOTH, expand=TRUE)
memimages=[]
for row_index in range(8):
for col_index in range(8):
iconimage = PhotoImage(file="test.gif")
b=Button(cv,image=iconimage)
memimages.append(iconimage)
b.grid(row=row_index, column=col_index, sticky=N+S+E+W)
mainloop()
main()
(edit) according to Bryan's answer, I made it work by adding this - note that fcv is not packed.
fcv=Frame(root)
cv.create_window(0, 0, anchor = "nw", window=fcv)
and all the buttons are children of fcv: b=Button(fcv,image=iconimage)
I still dont understand why the documentation (e.g.infohost or tutorialspot) doesnt mention this important fact.