[Tutor] e: moving from pack to grid in tkinter

Tony Cappellini cappy2112 at gmail.com
Mon Nov 27 18:32:54 CET 2006


Date: Mon, 27 Nov 2006 18:07:33 +1300
From: "John Fouhy" <john at fouhy.net>
Subject: Re: [Tutor] moving from pack to grid in tkinter
To: tutor-python <tutor at python.org>
Message-ID: <5e58f2e40611262107j2a55cdw32da4359d38c40a at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 27/11/06, Tony Cappellini <cappy2112 at gmail.com> wrote:
> I've got a main window which is 640 * 400.
>       self.root.geometry("600x400")
>
>  self.label.pack(side=BOTTOM, fill=X)
> This line would put the label at the bottom of the window, and extend to
> both left and right edges of the window.

>>So, something like a status bar?
Yes exactly. I started with pack- and the status bar was ok.
Then I read the pdf at Effbot.org. I need to add several widgets to the main
frame, so I figured I would use grid for all of them.

Using pack() is really the easiest way to do this.  Here's what I'd do:
>>
But i'm trying to get away from pack() and use grid()


>>Not sure why you have two column= options here.. One of them should be
>>columnspan, maybe?
Just a typi- I originally had columnspan, to see how it affected the widget-
it didnt'.
I was in the middle of an edit when I decided to post the message- but I had
tried cloumn with and without columnspan, no effect.

>>Using grid geometry, widgets will take their natural size and sit in
>>the middle of the cell you place them in.  If you want to override
>>this, you need to specify which edge or edges you want the widget to
>>stick to.

>>self.label.grid(row=5, column=0, columnspan=2, sticky=E+W)
I tried sticky E+W- again no effect on the edges of the label:(

>>f there is nothing in a row, the row will have a height of zero.  So
So how does one place a label (or any other widget) at the bottom row of a
screen using grid()?
It worked fine using pack- but the turoail pdf recommended grid() is easier
when working with several widgets in a common container widget

>>HTH!
Well thanks anyway. The pdf has really confused me.
Is there an official tkinter.org doc reference or something?

--
John.


------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061127/cc8a5ec1/attachment.html 


More information about the Tutor mailing list