[Tkinter-discuss] grid manager does propagate width - why?
Helmut Jarausch
jarausch at igpm.rwth-aachen.de
Tue Jan 18 11:23:30 CET 2011
Hi,
I have two version of a simple labeled entry widget.
import Tkinter as Tk
class LabEntry(Tk.Entry) :
def __init__(self,root,label,**args) :
self.Frame= Tk.Frame(root)
Lab=Tk.Label(self.Frame,text=label)
Lab.grid(column=0,row=0)
Tk.Entry.__init__(self,self.Frame,**args)
self.grid(column=1,row=0)
def grid(self,**args) :
self.Frame.grid(**args)
def Finish() :
root.destroy()
root= Tk.Tk()
root.protocol('WM_DELETE_WINDOW',Finish)
Name= Tk.StringVar()
Name.set('')
NameF= Tk.Frame(root)
NameF.grid(column=0,row=0)
Tk.Label(NameF,text='Name :').grid(column=0,row=0)
NameE= Tk.Entry(NameF,textvariable=Name,width=25)
NameE.grid(column=1,row=0)
Tk.mainloop()
-------------------------------------------------
This version, which doesn't use LabEntry, reserves space for 25
characters in the entry widget.
But, replacing the last 6 lines by
NameE= LabEntry(root,'Name :',textvariable=Name,width=25)
NameE.grid(column=0,row=0)
Tk.mainloop()
the (internal) entry widget has only size 0 initially.
Why?
Many thanks for a hint,
Helmut.
More information about the Tkinter-discuss
mailing list