Version 11 of Maximizing a toplevel window

Updated 2004-09-21 22:12:39

FULLSCREEN

Maximizing a toplevel window: Customers sometimes want a window to come up maximized (they want it to be as though they had touched the fill-the-screen button in the window-manager's decoration).

      package require Tcl 8.2 ;# [package present] and [string equal]
      package require Tk
      proc maximize toplevel {
             # Unixoid window managers definitely can't rely on "wm ... zoom";
             #    can MacOS?
             # "wm state ..." only began to take "zoom" with version 8.3.
         if {([catch {package present Tk 8.3}] == 0) &&
              [string equal $::tcl_platform(platform) windows]} {
             wm state $toplevel zoomed
             return
         }
         pack propagate $toplevel 0
         update idletasks
         wm geometry $toplevel +0+0
         wm minsize $toplevel [winfo screenwidth $toplevel] \
                               [winfo screenheight $toplevel]
      } ;# [CL]

An alternative, to support Tcl/Tk versions older than 8.2 (at least 7.5/4.1):

      package require Tk
      proc maximize toplevel {
          global tcl_platform
              # [wm state] able to set state beginning with Tk 8.3.
              # "zoomed" state available only on Windows.
          if {![package vsatisfies [package provide Tk] 8.3]
              && ([string compare $tcl_platform(platform) windows] == 0)} {
              wm state $toplevel zoomed
              return
          }
          pack propagate $toplevel 0
          update idletasks
          wm geometry $toplevel +0+0
          wm minsize $toplevel [winfo screenwidth $toplevel] \
                               [winfo screenheight $toplevel]
      }

DGP


Someone who wants to pursue this for Win32 should examine http://user.cs.tu-berlin.de/~eserte/src/perl/Win32Util/


RS A one-liner that works on Windows 2000 (and should on others, too):

 wm overrideredirect . 1; wm geometry . [join [wm maxsize .] x]+0+0

Tkinter can do the same, of course [L1 ].


If you use the current version of Tk with Windows, this works:

    wm state . zoom