Tkinter menu item underline syntax [RESOLVED]
Peter Otten
__peter__ at web.de
Thu Jan 7 05:26:56 EST 2021
On 06/01/2021 22:03, Rich Shepard wrote:
> On Thu, 7 Jan 2021, Chris Angelico wrote:
>
>> Are you sure that this works? It's syntactically valid, but I don't
>> think it means what you think it does.
>
> ChrisA,
>
> I'm always open to learning. There's no error generated ... yet the
> application doesn' open so it's time to run it through pdb.
Spoiler: unless the name 'underline' is defined you get a NameError:
NameError: name 'underline' is not defined
If it is defined and self.callbacks is a dict you get a TypeError:
TypeError: unhashable type: 'slice'
because that's what a colon means in a context like
x[a:b]
From what you posted I would guess that underline is most likely a
keyword argument to the add_command() method:
file_menu.add_command(
label='New',
command=self.callbacks['file->new'],
underline=0,
accelerator='Ctrl+N'
)
More information about the Python-list
mailing list