Python Tkinter Scrollbar Shaky Scrolling Python Tkinter Scrollbar Shaky Scrolling tkinter tkinter

Python Tkinter Scrollbar Shaky Scrolling


While there may be other errors, you have one very critical flaw: you are creating a binding for the <Configure> event to self. Because self is the instance of the root window, every widget you create inherits this binding. Your resizeCanvas method is literally being called hundreds of times at startup, and hundreds of times when the window is resized.

You also have the problem where you are calling update in an event handler. As a general rule, this is bad. In effect, it's like calling mainloop in that it will not return until all events are processed. If your code causes more events to be processed (such as reconfiguring a window and causing the <configure> event to fire, you end up in a recursive loop.

You probably need to remove the calls to self.update() and/or replace them with the less dangerous self.update_idletasks(). You also need to either remove the <Configure> binding on self, or in the method you need to check for which widget caused the event to fire (ie: check that the event.widget is the root window).


Try first to save the canvas.create_window to a variable as following:

self.windows_item = canvas.create_window((0,0),window=frame,anchor='nw')

then at the end of resizeCanvas to call the following method:

def update(self):    "Update the canvas and the scrollregion"    self.update_idletasks()    canvas.config(scrollregion=canvas.bbox(self.windows_item))

Hope it helps!

Most of it found here: https://stackoverflow.com/a/47985165/2160507