On Wed, 20 Sep 2006 21:21:25 -0700 (PDT) Johnston Jiaa <[EMAIL PROTECTED]> wrote:
> 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) > > Hi Johnston, in order for the columns to actually expand you will have to use grid_columnconfigure(column, weight=1), in order to make sure all buttons have the same size you can calculate the maximum size of all buttons and pass it to grid_columnconfigure() as minsize before actually gridding them, like max = 0 for b in (self.settings_bttn, self.stats_bttn, self.proc_bttn): w = b.winfo_reqwidth() if w > max: max = w self.grid_columnconfigure(0, weight=1, minsize=max) # etc. self.settings_bttn.grid(row = 0, column = 2, columnspan = 2, sticky = EW) I hope this helps Michael _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor