I have made a tkinter window that is separated by two scrollable Canvas with its widgets inside.
Both canvas widgets has its own scrollbar and I have binded the <MouseWheel> event on every canvas to the scrollbar.
This cause that if the mouse is on the canvas, the scroll works well, but if the mouse is over a widget inside the canvas, it doesn't activate the event handler.
I have tried binding with bind_all:
canvas1.bind_all("<MouseWheel>",scrollcanvas1)
canvas2.bind_all("<MouseWheel>",scrollcanvas2)
But it activates both event handlers on every part on the window, so it doesn't works for me.
Another way to keep this work is with the <Motion> event, so when the mouse is over one canvas, the event activate the bind_all function of the canvas where the mouse is over and de-activate the other.
def enablecanvas1():
canvas1.bind_all("<MouseWheel>",scrollcanvas1)
canvas2.unbind("<MouseWheel>")
def enablecanvas2():
canvas2.bind_all("<MouseWheel>",scrollcanvas2)
canvas1.unbind("<MouseWheel>")
canvas1.bind("<Motion>",enablecanvas1)
canvas2.bind("<Motion>",enablecanvas2)
It works well, but the thing turns complicated if the widgets inside the canvas fill it, so it doesn't left any canvas surface to put the mouse over it and activate the handler.
So, is there any way to bind the handler to all the canvas child widgets to make this work?
Thanks.