Re: Tkinter menu item underline syntax [RESOLVED]

2021-01-07 Thread Rich Shepard
On Wed, 6 Jan 2021, Terry Reedy wrote: 'underline' has nothing to do with looking up the command in self.callbacks. It is a keyword parameter for the add_command method, and is handled like all other values passed by name, and as you did for the other arguments file_menu.add_command(

Re: Tkinter menu item underline syntax [RESOLVED]

2021-01-07 Thread Terry Reedy
On 1/6/2021 4:17 PM, Terry Reedy wrote: On 1/6/2021 4:03 PM, 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 generat

Re: Tkinter menu item underline syntax [RESOLVED]

2021-01-07 Thread Rich Shepard
On Thu, 7 Jan 2021, Peter Otten wrote: 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 con

Re: Tkinter menu item underline syntax [RESOLVED]

2021-01-07 Thread Peter Otten
On 06/01/2021 22:03, Grant Edwards wrote: I'm completely baffled by that. Can somebody explain how this expression is evaluated? self.callbacks['file->new', underline: 0] It appears that the dict callbacks is being accessed with the key of a tuple comprising a string and a slice. Huh? Y

Re: Tkinter menu item underline syntax [RESOLVED]

2021-01-07 Thread Peter Otten
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

Re: Tkinter menu item underline syntax [RESOLVED]

2021-01-06 Thread Chris Angelico
On Thu, Jan 7, 2021 at 9:22 AM Grant Edwards wrote: > > On 2021-01-06, Rich Shepard wrote: > > On Wed, 6 Jan 2021, 2qdxy4rzwzuui...@potatochowder.com wrote: > > > >> For the sake of future generations who may run into this issue, can you > >> post the complete, correct call to file_menu.add_comma

Re: Tkinter menu item underline syntax [RESOLVED]

2021-01-06 Thread Terry Reedy
On 1/6/2021 4:03 PM, 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

Re: Tkinter menu item underline syntax [RESOLVED]

2021-01-06 Thread Grant Edwards
On 2021-01-06, Rich Shepard wrote: > On Wed, 6 Jan 2021, 2qdxy4rzwzuui...@potatochowder.com wrote: > >> For the sake of future generations who may run into this issue, can you >> post the complete, correct call to file_menu.add_command? > > This is the working version of the stanza I initially pos

Re: Tkinter menu item underline syntax [RESOLVED]

2021-01-06 Thread Rich Shepard
On Thu, 7 Jan 2021, Chris Angelico wrote: Cool. Terry had something on the subject in the other thread; I think that's a good place to start. (I don't know much about Tkinter, this line of code just looked odd in general Python syntax.) ChrisA, It's been a long time since I wrote any Python c

Re: Tkinter menu item underline syntax [RESOLVED]

2021-01-06 Thread Chris Angelico
On Thu, Jan 7, 2021 at 8:04 AM 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

Re: Tkinter menu item underline syntax [RESOLVED]

2021-01-06 Thread Rich Shepard
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. Regards

Re: Tkinter menu item underline syntax [RESOLVED]

2021-01-06 Thread Chris Angelico
On Thu, Jan 7, 2021 at 7:43 AM Rich Shepard wrote: > This is the working version of the stanza I initially posted: > > file_menu.add_command( > label = 'New', > command = self.callbacks['file->new', underline: 0], > accelerator = 'Ctrl+N' > )

Re: Tkinter menu item underline syntax [RESOLVED]

2021-01-06 Thread Rich Shepard
On Wed, 6 Jan 2021, 2qdxy4rzwzuui...@potatochowder.com wrote: For the sake of future generations who may run into this issue, can you post the complete, correct call to file_menu.add_command? This is the working version of the stanza I initially posted: file_menu.add_command(

Re: Tkinter menu item underline syntax

2021-01-06 Thread Terry Reedy
On 1/6/2021 1:32 PM, Rich Shepard wrote: My application's menu has lines like this:     file_menu.add_command(     label = 'New',     command = self.callbacks['file->new', underline 0],     accelerator = 'Ctrl+N'     ) 'underline' has nothing to do with look

Re: Tkinter menu item underline syntax [RESOLVED]

2021-01-06 Thread 2QdxY4RzWzUUiLuE
On 2021-01-06 at 11:18:15 -0800, Rich Shepard wrote: > On Wed, 6 Jan 2021, 2qdxy4rzwzuui...@potatochowder.com wrote: > > > I'm not a TKinter expert (nor even a current user), but that line that > > begins with whitespace and "command =" looks suspicious. As far as I can > > see, Python is correc

Re: Tkinter menu item underline syntax [RESOLVED]

2021-01-06 Thread Rich Shepard
On Wed, 6 Jan 2021, 2qdxy4rzwzuui...@potatochowder.com wrote: I'm not a TKinter expert (nor even a current user), but that line that begins with whitespace and "command =" looks suspicious. As far as I can see, Python is correct to call it syntactically erroneous. Yes, the line above it needed

Re: Tkinter menu item underline syntax

2021-01-06 Thread 2QdxY4RzWzUUiLuE
On 2021-01-06 at 10:32:58 -0800, Rich Shepard wrote: > My application's menu has lines like this: > file_menu.add_command( > label = 'New', > command = self.callbacks['file->new', underline 0], > accelerator = 'Ctrl+N' > ) > > Python reports a

Tkinter menu item underline syntax

2021-01-06 Thread Rich Shepard
My application's menu has lines like this: file_menu.add_command( label = 'New', command = self.callbacks['file->new', underline 0], accelerator = 'Ctrl+N' ) Python reports a syntax error when specifying the string index to underline; it rejects