[Tkinter-discuss] Pmw Question

clnethery at juno.com clnethery at juno.com
Fri Mar 19 02:23:58 EST 2004


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)
HashBox1.pack(fill=X, expand=1, padx=1, pady=1)
HashBox2 = Pmw.EntryField(sc2, labelpos=W, labelmargin=1, validate = None)
HashBox2.pack(fill=X, expand=1, padx=1, pady=1)
HashBox1.place(relx=0.01, rely=0.01, anchor=NW)
HashBox2.place(relx=0.5, rely=0.01, anchor=NW)



root.mainloop()



I've removed most of the excess code, to make the remaining bad code easier to read.  If you replace "sc2 = Pmw.ScrolledFrame(HashBoxFrame)" with "sc2 = Frame(HashBoxFrame)" it displays the EntryFields as I would like to display them (except for the fact that they're not in a ScrolledFrame).



More information about the Tkinter-discuss mailing list