0

I have a frame inside of a Canvas with a scrollbar. I want to scroll inside that frame (ie use the middle button of my mouse).

This answer to another stackoverflow question should contain working code, but it is not.

How can I get this example to work?

Gradient
  • 2,253
  • 6
  • 25
  • 36

1 Answers1

0

For what I could understand from I want to scroll inside that frame (ie use the middle button of my mouse). You want to use the mouse wheel to scroll the frame right?

You can use <MouseWheel> virtual event to scroll the canvas and ultimately the frame.

<canvas>.create_window((0,0),window=<frame>,anchor='nw')
def _on_mousewheel(event):
    <canvas>.yview_scroll(-1*int(event.delta/120), "units")   
<canvas>.bind_all("<MouseWheel>", _on_mousewheel)
  • I also have a scrollable Listbox for which I did not have to setup any event and the mouse wheel works. Shouldn't the code in the link work as is? I was thinking that `onFrameConfigure` would make the mouse wheel scroll the frame. – Gradient Jul 21 '21 at 04:58