
Pmw.PanedWidget() - frame subdivided into several resizable panes
A paned widget is a container megawidget which manages a number of resizable frames, known as panes. Each pane may act as the container for other widgets. The user may interactively resize the panes by dragging a small rectangle (the handle) or the line between the panes (the separator). The panes may be arranged horizontally or vertically. Each pane may have maximum and minimum limits of its size.
Each pane has the following options. These may be set when creating or configuring a pane. The value of each option may be an integer, which specifies a pane size in pixels, or a real number between 0.0 and 1.0, which specifies a pane size proportional to the size of the entire paned widget.
        Frame, separator and handle components are created dynamically
        by the add() and insert() methods.  The components are of type
        Tkinter.Frame and are created with component groups of
        Frame, Separator and Handle respectively.
insert() with before
    set to the current number of panes.  The method returns the name
    component widget.
If the pane deleted was not the only pane in the paned widget, also delete the separator and handle components named separator-n and handle-n, where n is the number of panes remaining.
add().
The new pane is created as a Tkinter.Frame component named name. If this is not the only pane, a separator and handle are also created as components named separator-n and handle-n, where n is one less than the number of panes. The method returns the name component widget.
If oriented vertically, set the height of the paned widget to the sum of the requested heights of all panes and set the width to the maximum requested width of all panes.
class Demo:
    def __init__(self, parent):
        # Create a main PanedWidget with a few panes.
        self.pw = Pmw.PanedWidget(parent,
                orient='vertical',
                hull_borderwidth = 1,
                hull_relief = 'sunken',
                hull_width=300,
                hull_height=400)
        for self.numPanes in range(4):
            if self.numPanes == 1:
                name = 'Fixed size'
                pane = self.pw.add(name, min = .1, max = .1)
            else:
                name = 'Pane ' + str(self.numPanes)
                pane = self.pw.add(name, min = .1, size = .25)
            label = Tkinter.Label(pane, text = name)
            label.pack(side = 'left', expand = 1)
            button = Tkinter.Button(pane, text = 'Delete',
                    command = lambda s=self, n=name: s.deletePane(n))
            button.pack(side = 'left', expand = 1)
            # TODO: add buttons to invoke self.moveOneUp and self.moveOneUp.
        self.pw.pack(expand = 1, fill='both')
        buttonBox = Pmw.ButtonBox(parent)
        buttonBox.pack(fill = 'x')
        buttonBox.add('Add pane', command = self.addPane)   
        buttonBox.add('Move pane', command = self.move)   
        self.moveSrc = 0
        self.moveNewPos = 1
        self.moveBack = 0
    def move(self):
        numPanes = len(self.pw.panes())
        if numPanes == 0:
            print 'No panes to move!'
            return
        if self.moveSrc >= numPanes:
            self.moveSrc = numPanes - 1
        if self.moveNewPos >= numPanes:
            self.moveNewPos = numPanes - 1
        print 'Moving pane', self.moveSrc, 'to new position', self.moveNewPos
        self.pw.move(self.moveSrc, self.moveNewPos)
        self.moveSrc, self.moveNewPos = self.moveNewPos, self.moveSrc
        if self.moveBack:
            if self.moveNewPos == numPanes - 1:
                self.moveNewPos = 0
                if self.moveSrc == numPanes - 1:
                    self.moveSrc = 0
                else:
                    self.moveSrc = self.moveSrc + 1
            else:
                self.moveNewPos = self.moveNewPos + 1
        self.moveBack = not self.moveBack
    def addPane(self):
        self.numPanes = self.numPanes + 1
        name = 'Pane ' + str(self.numPanes)
        print 'Adding', name
        pane = self.pw.add(name, min = .1, size = .25)
        label = Tkinter.Label(pane, text = name)
        label.pack(side = 'left', expand = 1)
        button = Tkinter.Button(pane, text = 'Delete',
                command = lambda s=self, n=name: s.deletePane(n))
        button.pack(side = 'left', expand = 1)
        self.pw.updatelayout()
    def deletePane(self, name):
        print 'Deleting', name
        self.pw.delete(name)
        self.pw.updatelayout()
    def moveOneUp(self, name):
        self.pw.move(name, name, -1)
    def moveOneDown(self, name):
        self.pw.move(name, name, 1)
     
    
    Pmw 1.3 -
     7 Aug 2007
     - Home
    
Manual page last reviewed: 14 April 2001