Tkinter--Column Alignment in a Dialog

W

W. eWatson

The code below produces:

Label title frame
lat/long fields in a frame
Label
x,y label fields in a frame
Standard OK-Cancel buttons

How do I fix it so the lat/long left most field lines up with the x,y left
most field?

That is, I get something like:

Lat: BOX Long: BOX
pixel-x: BOX pixel-y: BOX
I want the second line to be pushed to the left. BOX is just a data entry
field. I want the two rows as far to the margin on the left.

# testTk.py
# Prototype for dialog
from Tkinter import *
from tkSimpleDialog import Dialog
import tkSimpleDialog
import tkMessageBox

class DialogPrototype(Dialog):

def body(self, master):

# Titles
fLocationTitle = Frame(master) # fL..., f for frame
fLocationTitle.pack()

# Frames
fLocationTitle = Frame(master)
fLocationTitle.pack()
fCoords = Frame(master)
fCoords.pack(side=TOP)
beef=Entry(fCoords,width=20)

fZenithTitle = Frame(master)
fZenithTitle.pack(side=TOP)
fZenith = Frame(master)
fZenith.pack(side=TOP)

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+E, padx=5,
pady=3)
lat = Entry(fCoords, width=12)
lat.grid(row=0, column=1)

Label(fCoords, text='Longitude:').grid(row=0, column=2, padx=5, pady=3)
long = Entry(fCoords, width=12)
long.grid(row=0, column=3)

# Zenith pixels
Label(fZenithTitle, text="Zenith Pixel
Position").grid(row=0,column=0, pady=4)

Label(fZenith, text='Zenith x:').grid(row=0, column=0, padx=5, pady=3)
zenith_x = Entry(fZenith, width=6)
zenith_x.grid(row=0, column=1)

Label(fZenith, text='Zenith y:').grid(row=0, column=2,padx=5,pady=3)
zenith_y = Entry(fZenith, width=6)
zenith_y.grid(row=0, column=3)
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)
--
W. eWatson

(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

Web Page: <www.speckledwithstars.net/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top