class Window(Frame)

A Window is a top-level component. In order to be visible on the screen, a component must be directly or indirectly contained in a window.

A newly-created window is initially hidden so that components can be added to it without unsightly flashing. Once constructed it should be shown using the show method.

The initial position of a window is determined in a platform-dependent way, and may not correspond to the initial values of its x and y properties. For example, standard-style windows might be staggered and dialog-style windows might be centred on the screen. However, once the window has been shown for the first time, the x and y properties will reflect its actual screen position, and changing them will move the window to the corresponding position.

A window can be given a list of window-specific menus that are to be available (along with the application-wide menus) only when that window is active. The manner in which these menus are presented is platform-dependent.

A window can be associated with a document. When this is done, the behaviour of the window changes in the following ways:
The window's title will (by default) be derived automatically from the document's title.

Constructor

Window(style = 'standard',
  movable = default, closable = default, hidabledefault,
  resizable = default, zoomabledefault)

The style parameter determines the appearance of the window, according to platform conventions. It is one of:
  • 'standard'
  • 'nonmodal_dialog'
  • 'modal_dialog'
  • 'alert'

Not all of these styles are necessarily distinguishable on all platforms.

Note that the style only affects the appearance of the window, not its behaviour. For example, specifying the 'modal_dialog' style does not in itself cause the window to behave modally. For windows with specialized behaviour,  see the Dialog and ModalDialog classes.

The movable, closable, hidable, resizable and zoomable options request the presence or absence of controls for performing these functions. The default values of these options depend on the window style in a platform-dependent way. Also, some of these controls may not be available on some styles of window, in which case corresponding option will be ignored.

Properties

title
Title of the window. Whether and how the title is displayed depends on the window style and platform conventions.

document
The Document instance to which this window belongs, if any.

menus
List of window-specific menus, i.e. those which should be available only when this window is active.
Do not modify the contents of this list. To change it, you should construct a new list of menus and then assign the whole list to this property.

Methods

show()
Makes the window visible on the screen (by setting the visible property to true), and also brings it to the front.
hide()
Temporarily removes the window from the screen. Equivalent to setting the visible property to false.
bring_to_front()
Moves the window to the front of the stacking order. [NOT YET IMPLEMENTED]
send_to_back()
Moves the window to the back of the stacking order. [NOT YET IMPLEMENTED]
place_behind(window)
Places the window just behind the given window in the stacking order. [NOT YET IMPLEMENTED]

Abstract methods

update_title()
Called when the title of the document owning this window changes. By default it changes the window title to match the document title.
close_cmd()
Called in response to the Close menu command, or by activation of whatever gadget is used to close a window on the platform concerned. If the window belongs to a document and the document does not own any other windows, the document's close_cmd method is called. In any other case, the destroy method of this window is called.

Destructor

destroy()
Permanently removes the window from the screen, dissociates it from any document, and recursively destroys any sub-components. Neither the window nor any of its sub-components should be used again.

All windows and other components should be destroyed when they are no longer needed, otherwise they may not be garbage collected properly and may continue to tie up window system resources. This is taken care of by the framework when the user closes a window or document. In other situations you may need to call the destroy method yourself.