I have a window whose content changes. Sometimes the content is larger than the window, so the window expands to fit it\'s children. However, when I center a window using
When you call the geometry command, don't provide a width and height -- just supply the x/y values. When you give it an explicit width and height, you're telling Tk "I want the window to be exactly this size" so it turns it's auto-resize behavior off.
root.geometry("+%d+%d" % (rootsize + (x, y)))
Also, you can use winfo_width()
and winfo_height()
to get the actual size of the window, instead of parsing the output of the geometry
method.