Splitted Pane: Pmw.PanedWidget demonstration (pane factory) : Pmw Splitpane « GUI Pmw « Python






Splitted Pane: Pmw.PanedWidget demonstration (pane factory)

Splitted Pane: Pmw.PanedWidget demonstration (pane factory)
#Pmw copyright

#Copyright 1997-1999 Telstra Corporation Limited, Australia 
#Copyright 2000-2002 Really Good Software Pty Ltd, Australia

#Permission is hereby granted, free of charge, to any person obtaining a copy 
#of this software and associated documentation files (the "Software"), to deal 
#in the Software without restriction, including without limitation the rights 
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
#copies of the Software, and to permit persons to whom the Software is furnished 
#to do so, subject to the following conditions:

#The above copyright notice and this permission notice shall be included in all 
#copies or substantial portions of the Software.

#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
#INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
#PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
#HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
#OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
#SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 




title = 'Pmw.PanedWidget demonstration (pane factory)'

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

import Tkinter
import Pmw

class Demo:
    def __init__(self, parent):
  self.paneCount = 0

  # Create a "pane factory".
  label = Tkinter.Label(parent,
    pady = 10,
    text = 'Below is a simple "pane factory".\n' +
      'Drag the handle on the left\nto create new panes.')
  label.pack()
  self.factory = Pmw.PanedWidget(parent,
    orient='horizontal',
    command = self.resize,
    hull_borderwidth = 1,
    hull_relief = 'raised',
    hull_width=300, hull_height=200
                )
  self.factory.add('starter', size = 0.0)
  self.factory.add('main')
  button = Tkinter.Button(self.factory.pane('main'),
    text = 'Pane\n0')
  button.pack(expand = 1)
  self.factory.pack(expand = 1, fill = 'both')

    def resize(self, list):
  # Remove any panes less than 2 pixel wide.
  for i in range(len(list) - 1, 0, -1):
      if list[i] < 2:
    self.factory.delete(i)

  # If the user has dragged the left hand handle, create a new pane.
  if list[0] > 1:
      self.paneCount = self.paneCount + 1

      # Add a button to the new pane.
      name = self.factory.panes()[0]
      text = 'Pane\n' + str(self.paneCount)
      button = Tkinter.Button(self.factory.pane(name), text = text)
      button.pack(expand = 1)

      # Create a new starter pane.
      name = 'Pane ' + str(self.paneCount)
      self.factory.insert(name, size=0.0)

######################################################################

# Create demo in root window for testing.
if __name__ == '__main__':
    root = Tkinter.Tk()
    Pmw.initialise(root)
    root.title(title)

    exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
    exitButton.pack(side = 'bottom')
    widget = Demo(root)
    root.mainloop()


           
       








Related examples in the same category

1.Pmw.PanedWidget (Split pane): add, move and deletePmw.PanedWidget (Split pane): add, move and delete
2.Pmw.PanedWidget: add componentsPmw.PanedWidget: add components