How do I set the initial window size as the minimum window size in tkinter?

tkinter

Solution

You can also force an update right away without entering your mainloop, by using something like this:

root = Tk()
# set up widgets here, do your grid/pack/place
# root.geometry() will return '1x1+0+0' here
root.update()
# now root.geometry() returns valid size/placement
root.minsize(root.winfo_width(), root.winfo_height())

Description of update() at effbot tkinterbook:

Processes all pending events, calls event callbacks, completes any pending geometry management, redraws widgets as necessary, and calls all pending idle tasks. This method should be used with care, since it may lead to really nasty race conditions if called from the wrong place (from within an event callback, for example, or from a function that can in any way be called from an event callback, etc.). When in doubt, use update_idletasks instead.

I've used this a good deal while messing about trying to figure out how to do things like get the size/position of widgets before jumping into the main loop.

Problem

My understanding is that after initializing all frames and widgets in the `__init__` method, the tkinter window resizes to fit all these components. I would like to set the window's initialized size to be its minimum size. I want to be able to maximize and scale the window larger, but I never want the window to be small enough to start hiding widgets. How do I accomplish this?

Original source