Which means '& string' in wxpython / python

I'm a noob with Python. I read the wxPython Linux Tutorial.

and found that there is a '&' in front of the lines, for example:

Then we add some items into the menu. This can be done in two ways. file.Append(101, '&Open', 'Open a new document') file.Append(102, '&Save', 'Save the document') 

and

 Menus are then added into the menubar. menubar.Append(file, '&File') menubar.Append(edit, '&Edit') 

What is the meaning of & ?

Thanks for the help!

+4
source share
1 answer

The accelerator letter is indicated in the menu.

You can go to this menu item when the menu is open, and you press this letter on the keyboard or as a combination of keys together with a modifier key ( ALT-F to open an entry in the File menu, etc.).

From the documentation :

The label string for ordinary menu items (not separators) may include an accelerator that you can use to activate a menu item from the keyboard. The accelerator key can be set using the ampersand & symbol. To insert an ampersand character in the text of a menu item, the ampersand must be doubled.

Using ampersand to mark an accelerator key is not limited to wxPython; This is an agreement introduced by Microsoft Windows, and you will find that it is used in many different graphical interfaces. According to Wikipedia :

This convention arose in the first WIN32 api and is used in Windows Forms, and is also copied to many other entries on several operating systems.

+7
source

Source: https://habr.com/ru/post/1496106/


All Articles