Widget geometry ?

Pierre Quentel quentel.pierre at wanadoo.fr
Sat Mar 12 02:46:51 EST 2005


PGMoscatt a écrit :
> Hi All,
> 
> I am trying to create a dialog which will have a number of components but
> having trouble with the placement of various widgets.
> 
> For example, in my code below you will see I am trying to insert alabel but
> I want the label to be in the top-left of the dialog but it dosen't want to
> go there.
> 
> What am I doing wrong ?
> 
> Pete
> 
> 
> 
> from Tkinter import *
> 
> class show_settings_dialog:
>  def __init__(self,parent):
>   top = self.top = Toplevel(parent)
>   top.title("General Settings...")
>   top["height"]=300
>   top["width"]=300
>   top.pack_propagate(0)
> 
>   l1 = Label(top,text="User Name:").grid(row=0, sticky=W)
>     
>   b = Button(top,text="Ok",command=self.ok)
>   b.pack(pady=40)
>   
>   
>   
>  def ok(self):
>   self.top.destroy()
> 

You are mixing pack() and grid() to place widgets in the same container. 
Try doing b.grid(row=0,column=1) instead

Regards
Pierre



More information about the Python-list mailing list