back next

Toplevel Window Methods

This group of methods are used to communicate with the window manager. They are available on the root window (Tk), as well as on all Toplevel instances.

Note that different window managers behave in different ways. For example, some window managers don’t support icon windows, some don’t support window groups, etc.

Patterns

Displaying Windows

Window Properties

Icons

Reference

Wm (class) [#]

Wm implementation class. This class is used as a mixin by the root (Tk) and Toplevel widgets.

aspect(minNumer=None, minDenom=None, maxNumer=None, maxDenom=None) [#]

Controls the aspect ratio (the relation between width and height) of this window. The aspect ratio is constrained to lie between minNumer/minDenom and maxNumer/maxDenom.

If no arguments are given, this method returns the current constraints as a 4-tuple, if any.

Same as wm_aspect.

attributes(*args) [#]

Sets or gets window attributes. In Python 2.4, this wrapper is incomplete, and the application must use a non-standard syntax to modify and query the available attributes.

Same as wm_attributes.

*args
One or more attribute specifiers. The current version doesn’t support keyword arguments. Instead, you have to prefix the attribute name with a hyphen, and pass in the value as a separate argument (e.g. to set the “disabled” option, use attribute(“-disabled”, 1) instead of attribute(disabled=1)). If only an attribute name is given, the method returns the current value. If no arguments are given, the method returns the current attribute settings (see below for details).
alpha=
(Windows, Mac) Controls window transparency. 0.0 means fully transparent, 1.0 means fully opaque. This isn’t supported on all systems; where not supported, Tkinter always uses 1.0. Note that in this release, this attribute must be given as “-alpha”.
disabled=
(Windows) If set, disables the entire window. Note that in this release, this attribute must be given as “-disabled”.
modified=
(Mac) If set, the window is flagged as modified. Note that in this release, this attribute must be given as “-modified”.
titlepath=
(Mac) The path to the window proxy icon. Note that in this release, this attribute must be given as “-titlepath”.
toolwindow=
(Windows) If set, sets the window style to a “tool window”. Note that in this release, this attribute must be given as “-toolwindow”.
topmost=
(Windows) If set, this window is always placed on top of other windows. Note that in this release, this attribute must be given as “-topmost”.
Returns:
If an attribute value was specified, the return value is undefined. If a single attribute name was specified, this is the current attribute value (as a string). If no arguments where specified, this currently returns the current attribute values as a string, in the format “-attribute value -attribute value”. Future versions may return a dictionary instead.

client(name=None) [#]

Sets or gets the WM_CLIENT_MACHINE property. This property is used by window managers under the X window system. It is ignored on other platforms.

To remove the property, set it to an empty string.

Same as wm_client.

name
The new value for this property. If omitted, the current value is returned.

colormapwindows(*wlist) [#]

Sets or gets the WM_COLORMAP_WINDOWS property. This property is used by window managers under the X window system. It is ignored on other platforms.

Same as wm_colormapwindows.

wlist
The new value for this property. If omitted, the current value is returned.

command(value=None) [#]

Sets or gets the WM_COMMAND property. This property is used by window managers under the X window system. It is ignored on other platforms.

Same as wm_command.

wlist
The new value for this property. If omitted, the current value is returned. To remove the property, pass in an empty string.

deiconify() [#]

Displays the window. New windows are displayed by default, so you only have to use this method if you have used iconify or withdraw to remove the window from the screen.

Same as wm_deiconify.

focusmodel(model=None) [#]

Sets or gets the focus model.

Same as wm_focusmodel.

frame() [#]

Returns a string containing a system-specific window identifier corresponding to the window’s outermost parent. For Unix, this is the X window identifier. For Windows, this is the HWND cast to a long integer.

Note that if the window hasn’t been reparented by the window manager, this method returns the window identifier corresponding to the window itself.

Same as wm_frame.

geometry(geometry=None) [#]

Sets or gets the window geometry. If called with an argument, this changes the geometry. The argument should have the following format:

"%dx%d%+d%+d" % (width, height, xoffset, yoffset)

To convert a geometry string to pixel coordinates, you can use something like this:

import re
def parsegeometry(geometry):
    m = re.match("(\d+)x(\d+)([-+]\d+)([-+]\d+)", geometry)
    if not m:
        raise ValueError("failed to parse geometry string")
    return map(int, m.groups())
wm_geometry.

geometry
The new geometry setting. If omitted, the current setting is returned.

grid(baseWidth=None, baseHeight=None, widthInc=None, heightInc=None) [#]

The grid method. Same as wm_grid.

group(window=None) [#]

Adds window to the window group controlled by the given window. A group member is usually hidden when the group owner is iconified or withdrawn (the exact behavior depends on the window manager in use).

Same as wm_group.

window
The group owner. If omitted, the current owner is returned.

iconbitmap(bitmap=None) [#]

Sets or gets the icon bitmap to use when this window is iconified. This method is ignored by some window managers (including Windows).

Note that this method can only be used to display monochrome icons. To display a color icon, put it in a Label widget and display it using the iconwindow method instead.

Same as wm_iconbitmap.

iconify() [#]

Turns the window into an icon (without destroying it). To redraw the window, use deiconify. Under Windows, the window will show up in the taskbar.

When the window has been iconified, the state method returns “iconic”.

Same as wm_iconify.

iconmask(bitmap=None) [#]

Sets or gets the icon bitmap mask to use when this window is iconified. This method is ignored by some window managers (including Windows).

Same as wm_iconmask.

iconname(newName=None) [#]

Sets or gets the icon name to use when this window is iconified. This method is ignored by some window managers (including Windows).

Same as wm_iconname.

iconposition(x=None, y=None) [#]

Sets or gets the icon position hint to use when this window is iconified. This method is ignored by some window managers (including Windows).

Same as wm_iconposition.

iconwindow(window=None) [#]

Sets or gets the icon window to use as an icon when this window is iconified. This method is ignored by some window managers (including Windows).

Same as wm_iconwindow.

window
The new icon window. If omitted, the current window is returned.

maxsize(width=None, height=None) [#]

Sets or gets the maximum size for this window.

Same as wm_maxsize.

minsize(width=None, height=None) [#]

Sets or gets the minimum size for this window.

Same as wm_minsize.

overrideredirect(flag=None) [#]

Sets or gets the override redirect flag. If non-zero, this prevents the window manager from decorating the window. In other words, the window will not have a title or a border, and it cannot be moved or closed via ordinary means.

Same as wm_overrideredirect.

positionfrom(who=None) [#]

Sets or gets the position controller

Same as wm_positionfrom.

protocol(name=None, func=None) [#]

Registers a callback function for the given protocol. The name argument is typically one of “WM_DELETE_WINDOW” (the window is about to be deleted), “WM_SAVE_YOURSELF” (called by X window managers when the application should save a snapshot of its working set) or “WM_TAKE_FOCUS” (called by X window managers when the application receives focus).

Same as wm_protocol.

resizable(width=None, height=None) [#]

Sets or gets the resize flags. The width flag controls whether the window can be resized horizontally by the user. The height flag controls whether the window can be resized vertically.

Same as wm_resizable.

sizefrom(who=None) [#]

Sets or gets the size controller

Same as wm_sizefrom.

state(newstate=None) [#]

Sets or gets the window state. This is one of the values “normal”, “iconic” (see iconify, “withdrawn” (see withdraw) or “icon” (see iconwindow).

Same as wm_state.

title(string=None) [#]

Sets or gets the window title.

Same as wm_title.

title
The new window title. If omitted, the current title is returned.

transient(master=None) [#]

Makes window a transient window for the given master (if omitted, master defaults to self’s parent). A transient window is always drawn on top of its master, and is automatically hidden when the master is iconified or withdrawn. Under Windows, transient windows don’t show show up in the task bar.

Same as wm_transient.

withdraw() [#]

Removes the window from the screen (without destroying it). To redraw the window, use deiconify.

When the window has been withdrawn, the state method returns “withdrawn”.

Same as wm_withdraw.

wm_aspect(minNumer=None, minDenom=None, maxNumer=None, maxDenom=None) [#]

Controls the aspect ratio. See aspect for details.

wm_attributes(*args) [#]

Sets or gets window attributes. See attributes for details.

wm_client(name=None) [#]

Sets or gets the WM_CLIENT_MACHINE property. See client for details.

wm_colormapwindows(*wlist) [#]

Sets or gets the WM_COLORMAP_WINDOWS property. See colormapwindows for details.

wm_command(value=None) [#]

Sets or gets the WM_COMMAND property. See command for details.

wm_deiconify() [#]

Displays the window. See deiconify for details.

wm_focusmodel(model=None) [#]

Sets or gets the focus model. See focusmodel for details.

wm_frame() [#]

Returns a window identifier corresponding for the window’s outermost parent. See frame for details.

wm_geometry(newGeometry=None) [#]

Sets or gets the window geometry. See geometry for details.

wm_grid(baseWidth=None, baseHeight=None, widthInc=None, heightInc=None) [#]

See grid for details.

wm_group(pathName=None) [#]

Adds the window to a window group. See group for details.

wm_iconbitmap(bitmap=None) [#]

Sets or gets the icon bitmap. See iconbitmap for details.

wm_iconify() [#]

Turns the window into an icon. See iconify for details.

wm_iconmask(bitmap=None) [#]

Sets or gets the icon bitmap mask. See iconmask for details.

wm_iconname(newName=None) [#]

Sets or gets the icon name. See iconname for details.

wm_iconposition(x=None, y=None) [#]

Sets or gets the icon position hint. See iconposition for details.

wm_iconwindow(pathName=None) [#]

Sets or gets the icon window. See iconwindow for details.

wm_maxsize(width=None, height=None) [#]

Sets or gets the maximum size. See maxsize for details.

wm_minsize(width=None, height=None) [#]

Sets or gets the minimum size. See minsize for details.

wm_overrideredirect(boolean=None) [#]

Sets or gets the override redirect flag. See overrideredirect for details.

wm_positionfrom(who=None) [#]

See positionfrom for details.

wm_protocol(name=None, func=None) [#]

Registers a callback function for the given protocol. See protocol for details.

wm_resizable(width=None, height=None) [#]

Sets or gets the resize flags. See resizable for details.

wm_sizefrom(who=None) [#]

See sizefrom for details.

wm_state(newstate=None) [#]

Sets or gets the window state. See state for details.

wm_title(string=None) [#]

Sets or gets the window title. See title for details.

wm_transient(master=None) [#]

Makes window a transient window for a given master. See transient for details.

wm_withdraw() [#]

Removes the window from the screen. See withdraw for details.

 

A Django site. rendered by a django application. hosted by webfaction.