[Tutor] Tkinter, the correct way
Cameron Simpson
cs at cskk.id.au
Fri Feb 10 17:27:00 EST 2023
On 10Feb2023 15:40, Alan Gauld <alan.gauld at yahoo.co.uk> wrote:
>On 10/02/2023 09:00, Phil wrote:
>> value_label = ttk.Label(frame,
>> textvariable=self.value).grid(
>> column=2, row=2, sticky=(W, E))
>
>And this shouldn't work. grid() returns None.
>Hence your warning from VS.
Just to this. You may well want to keep a reference to the label (eg to
modify it). If so, you'd write:
value_label = ttk.Label(frame,_ textvariable=self.value)
value_label.grid(column=2, row=2, sticky=(W, E))
i.e. store the Label, then grid it. You were keeping the result of the
.grid(), not the Label itself.
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Tutor
mailing list