[Tkinter-discuss] divergent behaviour
Alan Gauld
alan.gauld at btinternet.com
Tue Jun 24 01:51:51 CEST 2014
On 24/06/14 00:27, Alan Gauld wrote:
>> I cannot see anything that looks critical here, how do you calculate the
>> Toplevel's coords in the MapEntry class?
>
> I don't, I just leave Tk to do its thing. Its a subclass of Fred's
> standard Dialog class with the body and apply methods overridden to
> populate the form with the original data and return the values
Here it is in its entirety.
class MapEntry(Dialog):
def __init__(self, parent, data):
self.data = data
Dialog.__init__(self, parent, title="History Editor")
def body(self, parent):
tk.Label(parent,
text="Map: %s" % self.data[0]).grid(row=0, sticky="W")
tk.Label(parent, text="Publisher: ").grid(row=1, sticky="W")
self.ePub = tk.Entry(parent)
self.ePub.insert(tk.END, self.data[1].strip() + ' '
+self.data[2].strip()) # initial & name
self.ePub.grid(row=1, column=1)
tk.Label(parent, text="Date Out: ").grid(row=2, sticky="W")
self.eDO = tk.Entry(parent)
self.eDO.insert(tk.END, self.data[3].strip())
self.eDO.grid(row=2, column=1)
tk.Label(parent, text="Date In: ").grid(row=3, sticky="W")
self.eDI = tk.Entry(parent)
self.eDI.insert(tk.END, self.data[4].strip())
self.eDI.grid(row=3, column=1)
return self.ePub
def apply(self):
self.result = (self.data[0],self.ePub.get(),
self.eDO.get(),self.eDI.get())
One thing to add is that I'm using tix, not standard Tk widgets,
but I don't think that should affect anything...
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
More information about the Tkinter-discuss
mailing list