Version 0 of wm minsize

Updated 2004-10-27 09:59:49

Automatically Setting Minimum Size of a Dialog

After packing or gridding a Tk dialog, the window can be resized at will by the user unless a minsize/maxsize has been specified or the wm resizable command has turned off resizing. This allows the user to shrink the dialog to smaller than the original size arrived at after packing/gridding. If you want to fix the minimum size to be that which has been decided by the pack/grid managers, pass your window to the proc shown below after you have packed/gridded all dialog elements:

   proc setDialogMinsize {window} {
      # this update will ensure that winfo will return the correct sizes
      update

      # get the current width and height
      set winWidth [winfo width $window]
      set winHeight [winfo height $window]

      # set it as the minimum size
      wm minsize $window $winWidth $winHeight
   }

Pass a window into this proc and it will set its minimum size to be whatever size it is currently. You will be able to make the window larger obviously (unless you set a wm maxsize on it).

It would be good if there was a wm-like command to do this automatically. (is there?)

-- Michael Eisemuth