""" Demonstration of the Pmw ScrolledFrame megawidget.
"""

# Import Pmw from the sibling directory.
import sys
sys.path[:0] = ['../../..']

import Tkinter
import Pmw

class Demo:
    def __init__(self, parent):
	# Create and pack the ScrolledFrame.
	self.sf = Pmw.ScrolledFrame(parent)
	self.sf.pack(padx = 10, pady = 10, fill = 'both', expand = 1)
	self.frame = self.sf.getFrame()
	button = Tkinter.Button(self.frame,
	    text = "Add a button",
	    command = self.addButton)
	button.pack()

    def addButton(self):
	button = Tkinter.Button(self.frame,
	    text = "Add another button",
	    command = self.addButton)
	button.pack()
	self.sf.updateScrollbars()
                
######################################################################
 
# Create demo in root window for testing.
if __name__ == '__main__': 
    root = Tkinter.Tk()
    Pmw.initialise(root, fontScheme = 'pmw1')
    root.title('Pmw ScrolledFrame demonstration')
 
    exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
    exitButton.pack(side = 'bottom')
    widget = Demo(root)
    root.mainloop() 
