]> SALOME platform Git repositories - tools/eficas.git/blob - Pmw/Pmw_1_2/demos/WidgetDestroy.py
Salome HOME
Modif V6_4_°
[tools/eficas.git] / Pmw / Pmw_1_2 / demos / WidgetDestroy.py
1 title = 'Demonstration of Pmw megawidget destruction'
2
3 # Import Pmw from this directory tree.
4 import sys
5 sys.path[:0] = ['../../..']
6
7 import Tkinter
8 import Pmw
9
10 class Demo:
11     def __init__(self, parent):
12         # Create and pack an EntryField.
13         self.entryfield = Pmw.EntryField(parent,
14             command = self.execute,
15             value = 'Press <Return> to destroy me',
16             entry_width = 30)
17         self.entryfield.pack(fill='x', expand=1, padx=10, pady=5)
18
19         self.entryfield.component('entry').focus_set()
20
21     def execute(self):
22         print 'Return pressed, destroying EntryField.'
23         self.entryfield.destroy()
24
25 ######################################################################
26
27 # Create demo in root window for testing.
28 if __name__ == '__main__':
29     root = Tkinter.Tk()
30     Pmw.initialise(root)
31     root.title(title)
32
33     exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
34     exitButton.pack(side = 'bottom')
35     widget = Demo(root)
36     root.mainloop()