Hi, that's an interesting way to look at it. Actually, I was about to probe the color idea myself, but needed to better understand how to achieve it. Where did grid_columnconfigure(3, weight=1) come from? I don't recall seeing that with Frame. Grid has columnconfigure. I started down that path once, but got waved off. Interesting about master.

What I've discovered is that I did not really understand the role of sticky, and the bounds of the label. I thought sticky=W  meant put the blasted label to the left margin. What sticky means, according to Grayson's chapter 5 on the web, is that it allows the widget to stretch when the larger window is resized.  Knowing the boundaries with color coding can help understand that, and other oddities. Label seems to always center the text. Changing the label's width and height achieves interesting insights. I tried anchor with Label and it does interesting things. The length of the text messes with matters.

To put some focus on what I think is the real problem, try this. See if the text in labels lines up on the left if a column of Labels is create with these labels.

vinegar
pie
latitude for x
Snowy

I haven't tried it yet, but would expect to get something like:

     vinegar
        pie
latitude for x
    Snowy

anchor with Label may move them to the left.

In my case, I'm looking for stuff like:

Latitude  BOX    Longitude  BOX
x  BOX  y BOX

and not
   Latitude BOX     Longitude BOX
          x BOX   y BOX

I want the text in the left column aligned. It doesn't really matter about the alignment of Longitude with y. One would think this would be a snap. I'm quite surprised no one seems to have considered an example along these lines. I guess everyone is center happy.

I have yet to find a good source that explains Grid in a thorough way. Lots of piecemeal things. Many too brief. Perhaps the best thing I've found is Grayson's chapter 5 image editor, p86f. He has a very complex looking grid of buttons, combo boxes and images, but it all makes sense as to the layout. It took me awhile to see why he needed so many rows and columns for those 9 (actually 10) thumbnails. It's all about what goes on in the lower right corner. Unfortunately, he had no need to align the text to the left uniformly in a column.

          WTW

W W wrote:
On Fri, Mar 27, 2009 at 2:46 PM, Wayne Watson <sierra_mtnv...@sbcglobal.net> wrote:
It's very difficult to tell. I've tried it.
        fLocation=Frame(master)
        fLocation.pack(side=LEFT)
I need to size the fLocation frame to make it big. As it is, it must be giving the smallest possible size.

I tried this
        fLocation.pack(expand=YES,fill=BOTH,side=TOP)

Good news... I got it!

Here's something that's often a good idea when debugging overlapping layouts (especially when you didn't design the parent!) - use different backgrounds!

First I tried grid_rowconfigure and grid_columnconfigure (which are necessary if you want your widgets in grid to resize and sticky in the expected places... at least in my experience. You call them on the parent widget which can be displayed with .pack() ) on fCoords - the parent of your labels. That didn't do anything, so I suspected the problem went deeper. So I tried fCoords parent, fLocation. That didn't do anything, so I finally went to /it's/ parent - master. By setting master.pack(expand=1, fill=BOTH) along with some other tweaks I was able to get some behavior I think you'll want.

I've left my background and border changes so you can get a better idea of what I did. Feel free to play around with the colors, borders, sticky options, and sizes of things. It'll probably help you to get a better grasp of what's going on.

Here's my changes (also found here: http://rafb.net/p/clKroD65.html )

# Framing it
from   Tkinter import *

from   tkSimpleDialog import Dialog
import tkSimpleDialog
import tkMessageBox
 
class DialogPrototype(Dialog):

 
    def body(self, master):
            # Frames
        master.configure(bg='white', bd=3)
        master.pack(expand=1, fill=BOTH)

        fLocationTitle = Frame(master, bg='green', bd=3)  # fL... f for frame
        fLocationTitle.pack()
        fLocation=Frame(master, bg='red', bd=3)

        fLocation.pack(expand=1, fill=BOTH, anchor=W)
        fCoords = Frame(fLocation, bg='blue', bd=3)      # lat/long coords in a frame
        fCoords.pack(fill=BOTH, expand=1, side=LEFT)

        fCoords.grid_columnconfigure(0, weight=0)
        fCoords.grid_columnconfigure(1, weight=1)
        fCoords.grid_columnconfigure(2, weight=0)
        fCoords.grid_columnconfigure(3, weight=1)
        fCoords.grid_rowconfigure(0, weight=1, minsize=1)

 
 
        self.title("Enter Site/Misc. Data")
 
        # Latitude and Longitude
 
        Label(fLocationTitle, text="Geographic Location").grid(row=0,column=0)

        #Label(fCoords, text='Latitude:').grid(row=0, sticky=W)
        self.lab=Label(fCoords, text='Latitude:', height=5)
        self.lab.grid(row=0, column=0, sticky=W)

        self.lat = Entry(fCoords, width=12)
        self.lat.grid(row=0, column=1, sticky=W+E)
 
        Label(fCoords, text='Longitude:').grid(row=0, column=2)
        self.long = Entry(fCoords, width=12)

        self.long.grid(row=0, column=3, sticky=W+E)
 
        return
 
    def apply(self):
        print "apply"

        print self.lat.get()
        print self.long.get()
 
    print "setting"
    lat=1.0

    long=0.0
 
 
root = Tk()
root.withdraw()
DialogPrototype(root)
HTH,
The -other- Wayne

--
Signature.html
           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

             (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


                Life is one damn thing after another."
                     -- Mark Twain 
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to