title
= 'Pmw.MessageBar demonstration'
# Import Pmw from this directory tree.
sys
.path
[:0] = ['../../..']
def __init__(self
, parent
):
# Create and pack the MessageBar.
self
._messagebar
= Pmw
.MessageBar(parent
,
self
._messagebar
.pack(side
= 'bottom', fill
= 'x',
expand
= 1, padx
= 10, pady
= 10)
# Create and pack the ScrolledListBox to change the MessageBar.
self
.box
= Pmw
.ScrolledListBox(parent
,
listbox_selectmode
='single',
items
=('state', 'help', 'userevent', 'systemevent',
'usererror', 'systemerror', 'busy',),
label_text
='Message type',
selectioncommand
=self
.selectionCommand
)
self
.box
.pack(fill
= 'both', expand
= 'yes', padx
= 10, pady
= 10)
def selectionCommand(self
):
sels
= self
.box
.getcurselection()
self
._index
= self
._index
+ 1
if messagetype
== 'state':
self
._stateCounter
= (self
._stateCounter
+ 1) % 3
text
= stateMessages
[self
._stateCounter
]
text
= text
+ ' (' + messagetype
+ ')'
self
._messagebar
.message('state', text
)
text
= messages
[messagetype
]
text
= text
+ ' (' + messagetype
+ ')'
self
._messagebar
.message(messagetype
, text
)
if messagetype
== 'busy':
self
._messagebar
.resetmessages('busy')
text
= 'All files successfully removed'
text
= text
+ ' (userevent)'
self
._messagebar
.message('userevent', text
)
'help': 'Save current file',
'userevent': 'Saving file "foo"',
'busy': 'Busy deleting all files from file system ...',
'systemevent': 'File "foo" saved',
'usererror': 'Invalid file name "foo/bar"',
'systemerror': 'Failed to save file: file system full',
2: 'Waiting for reply from database',
######################################################################
# Create demo in root window for testing.
if __name__
== '__main__':
exitButton
= Tkinter
.Button(root
, text
= 'Exit', command
= root
.destroy
)
exitButton
.pack(side
= 'bottom')