<meta name=
"description" content=
"Pmw - a toolkit for building high-level compound widgets in Python">
<meta name=
"content" content=
"python, megawidget, mega widget, compound widget, gui, tkinter">
<title>Pmw.Dialog reference manual
</title>
<body bgcolor=
"#ffffff" text=
"#000000" link=
"#0000ee"
vlink=
"551a8b" alink=
"ff0000">
<h1 ALIGN=
"CENTER">Pmw.Dialog
</h1>
<center><IMG SRC=Dialog.gif
ALT=
"" WIDTH=
374 HEIGHT=
162></center>
<dt> <h3>Name
</h3></dt><dd>
toplevel window with button box
<dt> <h3>Inherits
</h3></dt><dd>
<a href=
"MegaToplevel.html">Pmw.MegaToplevel
</a><br>
<dt> <h3>Description
</h3></dt><dd>
A dialog is a toplevel window composed of a button box and a child
site area. The child site area can be used to specialise the
megawidget by creating other widgets within it. This can be done
by using this class directly or by deriving from it.
</p>
<dt> <h3>Options
</h3></dt><dd>
Options for this megawidget and its base
classes are described below.
<p></p>
<a name=option.activatecommand
></a>
<dl><dt> <strong>activatecommand
If this is callable, it will be called whenever the megawidget is
activated by a call to
<code>activate()
</code>. The default is
<strong>None
</strong>.
</p>
<a name=option.buttonboxpos
></a>
<dl><dt> <strong>buttonboxpos
Initialisation option. Specifies on which side of the dialog window to place the button
box. Must be one of
<strong>'n'
</strong>,
<strong>'s'
</strong>,
<strong>'e'
</strong> or
<strong>'w'
</strong>. The default is
<strong>'s'
</strong>.
</p>
<a name=option.buttons
></a>
This must be a tuple or a list and specifies the names on the
buttons in the button box. The default is
<strong>('OK',)
</strong>.
</p>
<a name=option.command
></a>
Specifies a function to call whenever a button in the button box
is invoked or the window is deleted by the window manager. The
function is called with a single argument, which is the name of
the button which was invoked, or
<strong>None
</strong> if the window was deleted
by the window manager.
</p>
<p> If the value of
<strong>command
</strong> is not callable, the default behaviour
is to deactivate the window if it is active, or withdraw the
window if it is not active. If it is deactivated,
<code>deactivate()
</code>
is called with the button name or
<strong>None
</strong> as described above. The default is
<strong>None
</strong>.
</p>
<a name=option.deactivatecommand
></a>
<dl><dt> <strong>deactivatecommand
If this is callable, it will be called whenever the megawidget is
deactivated by a call to
<code>deactivate()
</code>. The default is
<strong>None
</strong>.
</p>
<a name=option.defaultbutton
></a>
<dl><dt> <strong>defaultbutton
Specifies the default button in the button box. If the
<strong><Return
></strong>
key is hit when the dialog has focus, the default button will be
invoked. If
<strong>defaultbutton
</strong> is
<strong>None
</strong>, there will be no default
button and hitting the
<strong><Return
></strong> key will have no effect. The default is
<strong>None
</strong>.
</p>
<a name=option.master
></a>
This is used by the
<code>activate()
</code> method to control whether the
window is made
<em>transient
</em> during modal dialogs. See the
<code>activate()
</code> method. The default is
<strong>'parent'
</strong>.
</p>
<a name=option.separatorwidth
></a>
<dl><dt> <strong>separatorwidth
Initialisation option. If this is greater than
<strong>0</strong>, a separator line with the specified
width will be created between the button box and the child site,
as a component named
<strong>separator
</strong>. Since the default border of the
button box and child site is
<strong>raised
</strong>, this option does not
usually need to be set for there to be a visual separation between
the button box and child site. The default is
<strong>0</strong>.
</p>
<a name=option.title
></a>
This is the title that the window manager displays in the title
bar of the window. The default is
<strong>None
</strong>.
</p>
<dt> <h3>Components
</h3></dt><dd>
Components created by this megawidget and its base
classes are described below.
<p></p>
<a name=component.buttonbox
></a>
<dl><dt> <strong>buttonbox
This is the button box containing the buttons for the dialog. By
default it is created with the options
<code>(hull_borderwidth =
1, hull_relief = 'raised')
</code>. By default, this component is a
<a href=
"ButtonBox.html">Pmw.ButtonBox
</a>.
</p>
<a name=component.dialogchildsite
></a>
<dl><dt> <strong>dialogchildsite
This is the child site for the dialog, which may be used to
specialise the megawidget by creating other widgets within it. By
default it is created with the options
<code>(borderwidth =
1, relief = 'raised')
</code>. By default, this component is a Tkinter.Frame.
</p>
<a name=component.hull
></a>
This acts as the body for the entire megawidget. Other components
are created as children of the hull to further specialise this
class. By default, this component is a Tkinter.Toplevel.
</p>
<a name=component.separator
></a>
<dl><dt> <strong>separator
If the
<strong>separatorwidth
</strong> initialisation option is non-zero, the
<strong>separator
</strong> component is the line dividing the area between the
button box and the child site. By default, this component is a Tkinter.Frame.
</p>
<dt> <h3>Methods
</h3></dt><dd>
Only methods specific to this megawidget are described below.
For a description of its inherited methods, see the
manual for its base class
<strong><a href=
"MegaToplevel.html#methods">Pmw.MegaToplevel
</a></strong>.
<a name=method.interior
></a>
<dl><dt> <strong>interior
</strong>()
</dt><dd>
Return the child site for the dialog. This is the same as
<code>component('dialogchildsite')
</code>.
</p>
<a name=method.invoke
></a>
<dl><dt> <strong>invoke
</strong>(
<em>index
</em> =
<strong>Pmw.DEFAULT
</strong>)
</dt><dd>
Invoke the command specified by the
<strong>command
</strong> option as if the
button specified by
<em>index
</em> had been pressed and return the
result.
<em>index
</em> may have any of the forms accepted by the
<a href=
"ButtonBox.html">Pmw.ButtonBox
</a> <code>index()
</code> method.
</p>
<dt> <h3>Example
</h3></dt><dd>
The image at the top of this manual is a snapshot
of the window (or part of the window) produced
by the following code.
<p></p>
def __init__(self, parent):
# Create two buttons to launch the dialog.
w = Tkinter.Button(parent, text = 'Show application modal dialog',
command = self.showAppModal)
w.pack(padx =
8, pady =
8)
w = Tkinter.Button(parent, text = 'Show global modal dialog',
command = self.showGlobalModal)
w.pack(padx =
8, pady =
8)
w = Tkinter.Button(parent, text = 'Show dialog with
"no grab"',
command = self.showDialogNoGrab)
w.pack(padx =
8, pady =
8)
w = Tkinter.Button(parent, text =
'Show toplevel window which\n' +
'will not get a busy cursor',
command = self.showExcludedWindow)
w.pack(padx =
8, pady =
8)
self.dialog = Pmw.Dialog(parent,
buttons = ('OK', 'Apply', 'Cancel', 'Help'),
# Add some contents to the dialog.
w = Tkinter.Label(self.dialog.interior(),
text = 'Pmw Dialog\n(put your widgets here)',
w.pack(expand =
1, fill = 'both', padx =
4, pady =
4)
# Create the window excluded from showbusycursor.
self.excluded = Pmw.MessageDialog(parent,
'This window will not get\n' +
'a busy cursor when modal dialogs\n' +
'are activated. In addition,\n' +
'you can still interact with\n' +
'this window when a
"no grab"\n' +
'modal dialog is displayed.')
Pmw.setbusycursorattributes(self.excluded.component('hull'),
self.dialog.activate(geometry = 'centerscreenalways')
def showGlobalModal(self):
self.dialog.activate(globalMode =
1)
def showDialogNoGrab(self):
self.dialog.activate(globalMode = 'nograb')
def showExcludedWindow(self):
def execute(self, result):
print 'You clicked on', result
if result not in ('Apply', 'Help'):
self.dialog.deactivate(result)
<center><P ALIGN=
"CENTER">
<IMG SRC = blue_line.gif ALT =
"" WIDTH=
320 HEIGHT=
5>
<center><P ALIGN=
"CENTER">
-
<a href=
"index.html">Home
</a>
<br>Manual page last reviewed:
18 May
2002