By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,034 Members | 1,325 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,034 IT Pros & Developers. It's quick & easy.

Widget geometry ?

P: n/a
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()

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Jul 18 '05 #2

P: n/a
Thanks Pierre.... all working now.

Pete
Pierre Quentel wrote:
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


Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.