1 title = 'Pmw.PanedWidget demonstration (pane factory)'
3 # Import Pmw from this directory tree.
5 sys.path[:0] = ['../../..']
11 def __init__(self, parent):
14 # Create a "pane factory".
15 label = Tkinter.Label(parent,
17 text = 'Below is a simple "pane factory".\n' +
18 'Drag the handle on the left\nto create new panes.')
20 self.factory = Pmw.PanedWidget(parent,
22 command = self.resize,
24 hull_relief = 'raised',
25 hull_width=300, hull_height=200
27 self.factory.add('starter', size = 0.0)
28 self.factory.add('main')
29 button = Tkinter.Button(self.factory.pane('main'),
31 button.pack(expand = 1)
32 self.factory.pack(expand = 1, fill = 'both')
34 def resize(self, list):
35 # Remove any panes less than 2 pixel wide.
36 for i in range(len(list) - 1, 0, -1):
38 self.factory.delete(i)
40 # If the user has dragged the left hand handle, create a new pane.
42 self.paneCount = self.paneCount + 1
44 # Add a button to the new pane.
45 name = self.factory.panes()[0]
46 text = 'Pane\n' + str(self.paneCount)
47 button = Tkinter.Button(self.factory.pane(name), text = text)
48 button.pack(expand = 1)
50 # Create a new starter pane.
51 name = 'Pane ' + str(self.paneCount)
52 self.factory.insert(name, size=0.0)
54 ######################################################################
56 # Create demo in root window for testing.
57 if __name__ == '__main__':
62 exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
63 exitButton.pack(side = 'bottom')