title
= 'Pmw.ButtonBox demonstration'
# Import Pmw from this directory tree.
sys
.path
[:0] = ['../../..']
def __init__(self
, parent
):
# Create and pack the ButtonBox.
self
.buttonBox
= Pmw
.ButtonBox(parent
,
label_text
= 'ButtonBox:',
self
.buttonBox
.pack(fill
= 'both', expand
= 1, padx
= 10, pady
= 10)
# Add some buttons to the ButtonBox.
self
.buttonBox
.add('OK', command
= self
.ok
)
self
.buttonBox
.add('Apply', command
= self
.apply)
self
.buttonBox
.add('Cancel', command
= self
.cancel
)
# Set the default button (the one executed when <Return> is hit).
self
.buttonBox
.setdefault('OK')
parent
.bind('<Return>', self
._processReturnKey
)
# Make all the buttons the same width.
self
.buttonBox
.alignbuttons()
def _processReturnKey(self
, event
):
print 'You clicked on OK'
print 'You clicked on Apply'
print 'You clicked on Cancel'
######################################################################
# Create demo in root window for testing.
if __name__
== '__main__':
exitButton
= Tkinter
.Button(root
, text
= 'Exit', command
= root
.destroy
)
exitButton
.pack(side
= 'bottom')