40f50f7d1c5ebf0a7c5f00e81b13f3fe22dc23a9
title
= 'Pmw.PromptDialog demonstration'
# Import Pmw from this directory tree.
sys
.path
[:0] = ['../../..']
# This may demonstrate a bug in Tk. Click on Cancel in the confirm
# dialog and then click on OK in the password dialog. Under Solaris
# 2.5 and python 1.5, the Cancel button in the confirm dialog is still
# displayed active, that is, it has a lighter background.
def __init__(self
, parent
):
# Create the dialog to prompt for the password.
self
.dialog
= Pmw
.PromptDialog(parent
,
label_text
= 'Password:',
entryfield_labelpos
= 'n',
buttons
= ('OK', 'Cancel'),
# Create the confirmation dialog.
self
.confirm
= Pmw
.MessageDialog(
message_text
= 'Are you really sure?',
buttons
= ('OK', 'Cancel'))
# Create button to launch the dialog.
w
= Tkinter
.Button(parent
, text
= 'Show prompt dialog',
command
= self
.dialog
.activate
)
w
.pack(padx
= 8, pady
= 8)
def execute(self
, result
):
if result
is None or result
== 'Cancel':
print 'Password prompt cancelled'
self
.dialog
.deactivate(result
)
result
= self
.confirm
.activate()
print 'Password entered ' + self
.dialog
.get()
######################################################################
# Create demo in root window for testing.
if __name__
== '__main__':
exitButton
= Tkinter
.Button(root
, text
= 'Exit', command
= root
.destroy
)
exitButton
.pack(side
= 'bottom')