[Tkinter-discuss] Pmw Question

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Fri Mar 19 02:45:53 EST 2004


clnethery at juno.com wrote:
> Sorry about that, I forgot to include a code example.  Let me warn you first... ..this is ugly, OOP newbie code (my imports probably illustrate that, for starters), but it replicates the problem:
> 
> 
> ### imports ###
> 
> import Tkinter
> from Tkinter import *
> from Tkconstants import *
> import idlelib.TreeWidget as tw
> import Pmw
> 
> from xml.dom.minidom import parseString
> from idlelib.TreeWidget import TreeItem, TreeNode
> 
> ### initialization ###
> 
> root = Tkinter.Tk()
> root.title('Agile Integration Tool')
> Pmw.initialise(root)
> 
> 
> ### menubar ###
> 
> mBar=Pmw.MenuBar(root, hull_relief='raised', hull_borderwidth=1)
> mBar.pack(fill='x')
> 
> mBar.addmenu('File', 'Close this window or exit')
> mBar.addcascademenu('File', 'New', 'Set some other preferences', traverseSpec = 'z', tearoff = 1)
> mBar.addmenuitem('File', 'command', 'Save this application', command='save', label='Save')
> mBar.addmenuitem('File', 'command', 'Open up SaveAs dialog', command='saveas', label='Save As')
> mBar.addmenuitem('File', 'separator')
> mBar.addmenuitem('File', 'command', 'Exit the application', command='exit', label='Exit')
> 
> 
> Mainframe = Frame(root, width=1015, height=708)
> Mainframe.pack(fill = 'both', expand = 1, padx = 5, pady = 5)
> Notebook = Pmw.NoteBook(Mainframe)
> Notebook.setnaturalsize()
> Notebook.pack(fill = 'both', expand = 1, padx = 5, pady = 5)
> Notebook1 = Notebook.add('General Stuff')
> 
> 
> Notebook1MainFrame = Frame(Notebook1, borderwidth=2, width=975, height=600, relief=GROOVE)
> Notebook1MainFrame.pack(fill = 'both', expand = 1, padx = 5, pady = 5)
> Notebook1MainFrame.place(relx=0.01, rely=0.01, anchor=NW)
> 
> Notebook1SubFrameRight = Frame(Notebook1MainFrame, borderwidth=2, relief=GROOVE, height=580, width=470)
> Notebook1SubFrameRight.pack(fill = 'both', expand = 1, padx = 5, pady = 5)
> Notebook1SubFrameRight.place(relx=0.5, rely=0.01, anchor=NW)
> 
> HashBoxFrame = Frame(Notebook1SubFrameRight, borderwidth=2, width=440, height=280, relief=GROOVE)
> HashBoxFrame.pack(padx=1, pady=1, fill='both', expand=1)
> HashBoxFrame.place(relx=0.02, rely=0.36, anchor=NW)
> 
> sc2 = Pmw.ScrolledFrame(HashBoxFrame)
> sc2.pack(fill=X, expand=1, padx=2, pady=2)
> sc2.place(relx=0.025, rely=0.025, anchor=NW)
> 
> HashBox1 = Pmw.EntryField(sc2, labelpos=W, labelmargin=1, validate = None)

To put anything into a ScrolledFrame you must use the interior() method
(so the scrolled frame can update its scrollbars I guess...

So:

HashBox1 = Pmw.EntryField(sc2.interior(), labelpos=W, labelmargin=1,
     validate = None)

etc..




HTH
Martin







More information about the Tkinter-discuss mailing list