Sep-13-2019, 01:22 PM
Hello,
I'm trying to create a image viewer in tkinter. I have problem with scrollbars in my app. I want horizontal and vertical scrollbars next to image when the image is zoomed. I use following code to do this (part of my code):
In what part of the code do I have a mistake?
Thank you, Christina
I'm trying to create a image viewer in tkinter. I have problem with scrollbars in my app. I want horizontal and vertical scrollbars next to image when the image is zoomed. I use following code to do this (part of my code):
image = Image.open(filename) photo = ImageTk.PhotoImage(image) ... if zoom > 1: canvas = Canvas(root, width = w*zoom, height = h*zoom, bg=bgcolor) canvas.pack(side="top", expand=1, fill=BOTH) scroll_bar_x = Scrollbar(canvas, orient = tkinter.HORIZONTAL) scroll_bar_x.pack(side="bottom", fill = X, expand= 0) scroll_bar_y = Scrollbar(canvas, orient = tkinter.VERTICAL) scroll_bar_y.pack(side="right", fill = Y, expand= 0) scroll_bar_x["command"] = canvas.xview scroll_bar_y["command"] = canvas.yview canvas["xscrollcommand"] = scroll_bar_x.set canvas["yscrollcommand"] = scroll_bar_y.set canvas.create_image(w*zoom/2, h*zoom/2, image=photo)I see scrollbars next to image but they don't work. I can't use them.
In what part of the code do I have a mistake?
Thank you, Christina