Pmw.MegaToplevel

Name

Pmw.MegaToplevel() - base class for megawidgets within a toplevel

Inherits

Pmw.MegaArchetype

Description

This class creates a megawidget contained within a toplevel window. It may be used directly to create a toplevel megawidget or it may be used as a base class for more specialised toplevel megawidgets, such as Pmw.Dialog. It creates a Tkinter.Toplevel component, named hull, to act as the container of the megawidget. The window class name for the hull widget is set to the most-specific class name for the megawidget. Derived classes specialise this widget by creating other widget components as children of the hull widget.

The megawidget may be used as either a normal toplevel window or as a modal dialog. Use show() and withdraw() for normal use and activate() and deactivate() for modal dialog use. If the window is deleted by the window manager while being shown normally, the default behaviour is to destroy the window. If the window is deleted by the window manager while the window is active (ie: when used as a modal dialog), the window is deactivated. Use the userdeletefunc() and usermodaldeletefunc() methods to override these behaviours. Do not call protocol() to set the WM_DELETE_WINDOW window manager protocol directly if you want to use this window as a modal dialog.

The currently active windows form a stack with the most recently activated window at the top of the stack. All mouse and keyboard events are sent to this top window. When it deactivates, the next window in the stack will start to receive events.

Options

Options for this megawidget and its base classes are described below.

activatecommand
If this is callable, it will be called whenever the megawidget is activated by a call to activate(). The default is None.

title
This is the title that the window manager displays in the title bar of the window. The default is None.

Components

Components created by this megawidget and its base classes are described below.

hull
This acts as the body for the entire megawidget. Other components are created as children of the hull to further specialise the widget. By default, this component is a Tkinter.Toplevel.

Methods

Only methods specific to this megawidget are described below. For a description of its inherited methods, see the manuals for its base classes. In addition, methods from Tkinter.Toplevel are forwarded to this megawidget's hull component.

activate(globalMode = 0, master = None)
Display the window, perform a grab operation and wait for the result. The window will be withdrawn, the grab released and the result returned when the deactivate() method is called.

If globalMode is 0, the window will grab control of the pointer and keyboard, preventing any events from being delivered to any other toplevel windows within the application. If globalMode is 1, the grab will prevent events from being delivered to any other toplevel windows regardless of application. Global grabs should be used sparingly.

When the window is displayed, it is is centred on the screen. Also, if the BLT Tcl extension library is present, a clock cursor will be displayed until the window is deactivated.

If the activatecommand option is callable, it is called just before the window begins to wait for the result.

If master is not None, the window will become a transient window of master. The master should should be another existing toplevel window.

active()
Return 1 if the megawidget is currently active (that is, activate() is currently waiting for a result to be passed to it by a call to deactivate()). Otherwise, return 0.

deactivate(result = None)
This should be called while a call to activate() is waiting. It will withdraw the window, release the grab and cause the activate() call to return with the value of result.

destroy()
Destroy the hull component widget, including all of its children. If the megawidget is currently active, deactivate it.

show()
Make the window visible. This raises or deiconifies the toplevel window. If the window has previously been shown it will remain in the same position. This means that calling withdraw() then show() will not move the window, whereas calling withdraw() then deiconify() may change the window's position. (This may depend on the behaviour of the window manager.)

userdeletefunc(func = None)
If func is None, return the function that will be called when the window is deleted by the window manager while being displayed normally. If func is not None, set this function to func. By default, the function is self.destroy.

usermodaldeletefunc(func = None)
If func is None, return the function that will be called when the window is deleted by the window manager while it is active (ie: when being used as a modal dialog). If func is not None, set this function to func. By default, the function is self.deactivate.

Home. Pmw 0.6.2 Maintainer gregm@iname.com. 23 Feb 1998