[Tutor] grid manager question

Sibylle Koczian nulla.epistola at web.de
Mon Feb 13 11:12:02 EST 2023


Am 13.02.2023 um 13:49 schrieb David:
> On Mon, 13 Feb 2023 at 20:43, Phil <phillor9 at gmail.com> wrote:
> 
>> The code below displays a list of circles, one per column.
> 
> Not for anyone except you it doesn't, because we can't 'import led3'.
> 
>> So far so
>> good until I add any other widget under the row of circles. If I add a
>> widget in column 8 then the circles are unaffected. If I add a widget
>> into any other column (not the same row as the circles) then the circles
>> move apart over that widget.
> 
> As Alan wrote, they move apart because they need to, so that the column
> can accomodate the widget that you add later, which is wider than the
> widget that you first put into the column.
> 

Or use the "columnspan" option in the call to grid for the button:

tk.Button(self, text='Turn On', 
command=self.led_list[1].turn_on).grid(row=3, column=2, columnspan=2, 
padx=5, pady=5)

I was lazy and looked this up in my very old Tkinter book. But I can't 
imagine that this option might have vanished or changed its name. 
Probably all GUI libraries know it. Of course there is also "rowspan".

HTH
Sibylle




More information about the Tutor mailing list