My top tip for doing anything requiring precise layout control
in Tkinter is use lots of Frames. Use grids pr packer inside the
frames as appropriate, but control the layout of the controls
inside a frame, then control the layout pof the frames inside
the main window and life generally gets easier IMHO.

In your case I'd have a frame for the 3 buttons, then another
frame for the text widget. grid the buttons inside the frame,
pack the text widget. Then grid the frames inside the main
window.

Putting borders and relief effects round the frames can
significantly improve the look of a Tkinter app too.

Alan G.

----- Original Message ----- 
From: "Johnston Jiaa" <[EMAIL PROTECTED]>
To: <tutor@python.org>
Sent: Thursday, September 21, 2006 5:21 AM
Subject: [Tutor] Tkinter GUI Grid Layout Manager


>I am trying to get 3 buttons, equally separated along the top of the 
>window.  How do I get them to all be the same size and how do I make 
>them so that they are equidistant to each other?
>
> Along with those three buttons, I am trying to get a text box, near 
> the middle of the window.  Every time I attempt to put this in, it 
> messes up the position of the top buttons.  My code follows:
>
>    # Top "Mode" Widgets
>    # Settings Button
>    self.settings_bttn = Button(self, text = "Settings")
>    self.settings_bttn.grid(row = 0, column = 2, columnspan = 2, 
> sticky = EW)
>
>    # Statistics Button
>    self.stats_bttn = Button(self, text = "Statistics")
>    self.stats_bttn.grid(row = 0, column = 5, columnspan = 2, sticky 
> = EW)
>
>    # Procrastinate Button
>    self.proc_bttn = Button(self, text = "Procrastinate")
>    self.proc_bttn.grid(row = 0, column = 8, columnspan = 2, sticky = 
> EW)
>
>
>    # Top-Mid Separator
>    self.top_mid_sep_lbl = Label(self, text = 
> "------------------------------------------------------------------------------------------------------")
>    self.top_mid_sep_lbl.grid(row = 1, column = 0, columnspan = 10, 
> sticky = EW)
>
>
>    # Mid Assignments Widgets
>    # Assignments Text Display
>    self.assign_disp_txt = Text(self, width = 30, height = 18, wrap = 
> WORD)
>    self.assign_disp_txt.grid(row =3, column = 1, columnspan = 5, 
> sticky = W)
>
>
> Thanks, Johnston Jiaa
>
>
> ---------------------------------
> Do you Yahoo!?
> Everyone is raving about the  all-new Yahoo! Mail. 

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to