I created a menu using:
fileMenu = wx.Menu()
fileMenu.Append(ID_NEW, "&New\tCtrl+N", "Creates a new file")
I can access New by clicking it on the menu or by clicking Ctrl+N.
My question is: What is the & stand for?
if I delete it everything is still working. However all guides still use it and none of them explain what is the purpose of it. I've read also here: http://wxpython.org/Phoenix/docs/html/MenuItem.html#MenuItem.SetItemLabel
"An accelerator key can be specified using the ampersand & character ... Optionally you can specify also an accelerator string appending a tab character \t followed by a valid key combination"
So according to this there is no need to use & if I use \t. can someone confirm if my conclusion is correct? I just can't figure why I always see both... there has to be a reason why everyone are using it this way.
The
&
characters in menu titles indicate an accelerator that you can press while the menu is open to quickly access the item. This only works when the menu is open and focused. You'll see the underscored character in the item title as a mnemonic. Same applies to the top level menu entry as well, such as 'File' or 'Edit': by standard WIMP convention you can open said menu using Alt-F (if F is the accelerator for File) and then just as quickly press 'C' if there is an accelerator for C in that menu. Quick and very little known these days.The
\t
means a tab in traditional context and in menu items it will make a global shortcut in your frame that you can press without the menu being active.