This is an unofficial mirror of Tkinter reference documentation (based on Python 2.7 and Tk 8.5) created by the late John Shipman.
It was last updated in 2013 and is unmaintained. [More info]
A top-level window is a window that has an independent existence under the window manager. It is decorated with the window manager's decorations, and can be moved and resized independently. Your application can use any number of top-level windows.
For any widget
, you can get to its top-level widget
To create a new top-level window:
Toplevel window methods
||The background color of the window. See Section 5.3, “Colors”.|
Border width in pixels; default is |
You can give a |
*Screamer*background: redand then, if you use the
||The cursor that appears when the mouse is in this window. See Section 5.8, “Cursors”.|
||Window height; see Section 5.1, “Dimensions”.|
|The color of the focus highlight when the window does not have focus. See Section 53, “Focus: routing keyboard input”.|
||The color of the focus highlight when the window has the focus.|
The thickness of the focus highlight. Default is
To provide this window with a top-level menubar,
supply a |
|Use this option to provide extra space on the left and right sides of the window. The value is a number of pixels.|
|Use this option to provide extra space on the top and bottom sides of the window. The value is a number of pixels.|
Normally, a top-level window will have no 3-d
borders around it. To get a shaded border, set the
Normally, a top-level window does not get focus.
||The desired width of the window; see Section 5.1, “Dimensions”.|
These methods are available for top-level windows:
Constrain the root window's width:length ratio to the
If this window is iconified, expand it.
Set the window geometry. For the form of the argument, see Section 5.10, “Geometry strings”. If the argument is omitted, the current geometry string is returned.
Iconify the window.
To raise this window to the top of the stacking order
in the window manager, call this method with no
arguments. You can also raise it to a position in
the stacking order just above another
Toplevel window by passing that window as an
If the argument is omitted, moves the window to the
bottom of the stacking order in the window manager.
You can also move the window to a position just under
some other top-level window by passing that
Toplevel widget as an argument.
Set the maximum window size. If the arguments are
omitted, returns the current
Set the minimum window size. If the arguments are omitted, returns the current minima as a 2-tuple.
If called with a
True argument, this
method sets the override redirect flag, which removes
all window manager decorations from the window, so
that it cannot be moved, resized, iconified, or
closed. If called with a
argument, window manager decorations are restored and
the override redirect flag is cleared. If called
with no argument, it returns the current state of the
override redirect flag.
Be sure to call the
.update_idletasks() method (see Section 26, “Universal widget methods”) before setting this flag. If
you call it before entering the main loop, your
window will be disabled before it ever appears.
This method may not work on some Unix and MacOS platforms.
is true, allow horizontal resizing. If
height is true, allow vertical resizing.
If the arguments are omitted, returns the current size as
Returns the window's current state, one of:
'normal': Displayed normally.
'iconic': Iconified with the
'withdrawn': Hidden; see the
.withdraw() method below.
To change the window's state, pass one of the strings
above as an argument to the method. For example, to
Set the window title. If the argument is omitted, returns the current title.
Make this window a transient window for some
the default parent window is this window's parent.
This method is useful for short-lived pop-up dialog windows. A transient window always appears in front of its parent. If the parent window is iconified, the transient is iconified as well.
Hides the window. Restore it with