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 both a space and an equals sign (=).

In "Modern Tkinter", page 88, the author explains,
"Underline
"While all platforms support keyboard traversal of the menubar via the arrow
keys, on Windows and X11, you can also use other keys to jump to particular
menus or menu items. The keys that trigger these jumps are indicated by an
underlined letter in the menu item’s label. If you want to add one of these
to a menu item, you can use the "underline" configuration option for the
item. The value of this option should be the index of the character you’d like
underlined (from 0 to the length of the string - 1)."

There is no example of the proper syntax and my web searches haven't found
one, either.

How do I pass a string index to the command to underline that character?

TIA,

Rich
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to