tkinter: tk.grid columnspan

Terry Reedy tjreedy at udel.edu
Wed Jun 5 17:19:10 EDT 2019


On 6/5/2019 4:45 PM, Rich Shepard wrote:
> In one row of a grid layout I have these two input widgets:
> 
>      self.inputs['name'] = LabelInput(
>              self, 'Site Name',
>              input_var=tk.StringVar(),
>              )
>          self.inputs['name'].grid(sticky=tk.W, row=0, column=0)
> 
>          self.inputs['description'] = LabelInput(
>              self, 'Site Description',
>              input_var=tk.StringVar(),
>          )
>          self.inputs['description'].grid(row=0, column=1, columnspan=2)
> 
> I want the second one (description) to be wider and thought the columnspan
> option would do the job. It does not. I've read several web pages on the
> tk.grid without seeing the proper way of making a stringvar wider than a
> single grid cell.
> 
> Please teach me how to make a tk.StingVar cover two columns in a grid
> layout.

Unless you specifiy otherwise through expand and weight options, grid 
columns are the minimum width required for the widest minimum width of 
any widget in the column.

The columnspan makes the minimum width of 'description' the minimum 
width of column 1 plus the minimum width of column 2.  With nothing else 
in columns 1 and 2, it has no effect.

Try reading the grid page at
http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html
if you can get it to load.  (I did a couple of days ago, but not today.)

-- 
Terry Jan Reedy





More information about the Python-list mailing list