How would I place an image inside of this code so it can scroll?
This code is from the answer here: tkinter: using scrollbars on a canvas
from tkinter import *
root=Tk()
frame=Frame(root,width=300,height=300)
frame.pack(expand=True, fill=BOTH) #.grid(row=0,column=0)
canvas=Canvas(frame,bg='#FFFFFF',width=300,height=300,scrollregion=(0,0,500,500))
hbar=Scrollbar(frame,orient=HORIZONTAL)
hbar.pack(side=BOTTOM,fill=X)
hbar.config(command=canvas.xview)
vbar=Scrollbar(frame,orient=VERTICAL)
vbar.pack(side=RIGHT,fill=Y)
vbar.config(command=canvas.yview)
canvas.config(width=300,height=300)
canvas.config(xscrollcommand=hbar.set, yscrollcommand=vbar.set)
canvas.pack(side=LEFT,expand=True,fill=BOTH)
root.mainloop()
I tried an image on the canvas, as well as an image inside another frame inside the canvas, and an image inside the existing frame, and I placed a label inside a nested frame and on existing canvas. The scroll bars don't function with the image that was larger than 300x300, but the scroll bars move with the label of only text, but the label doesn't move. I used L_text.place(x=20,y=90)
and I used L_text.pack()
with same results.
Without modification of code in the Answer, I get scrollbars to move and mousewheel moves them only when mouse pointer hovers on the vert scrollbar, but mouse on the canvas/frame area doesn't move the scrollbars.
Ubuntu 20.04 python 3.8.5