Can't scroll to things added to canvas by a button

Question:

I’m finishing building an app managing a JSON and while everything is scrolling when it’s added before the mainloop starts, if I add it by a button, I can’t scroll to the newly added things (I add them by canvas.create_window(0, getfirstfreeposition(), window=thing)). I have the grid weights set up to 1 on my Toplevel and Tk windows and "Configure"=lambda event:canvas.configure(scrollregion=canvas.bbox("all") on all canvases.

Edit: after a bit of research, reopening Toplevel window lest me scroll properly

Edit 2: link to repo with code: https://github.com/Gutek8134/AID-state-creator

Asked By: Ronin

||

Answers:

You need to reconfigure the scrollregion for the canvas whenever things are added to or removed from the canvas. It can be as simple as doing this after adding one or more items to the canvas:

the_canvas.configure(scrollregion=the_canvas.bbox("all"))
Answered By: Bryan Oakley
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.