Widget geometry ?

P

PGMoscatt

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()
 
P

Pierre Quentel

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
 
P

PGMoscatt

Thanks Pierre.... all working now.

Pete


Pierre said:
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
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top