1

Just started playing around with wxPython and came across the wx.Button class, can someone tell me what the '&' does in the sample labels, why it's there and why its in a different place for some, but not others, like below

wx.ID_CLOSE     '&Close'
wx.ID_COPY      '&Copy'
wx.ID_CUT       'Cu&t' 

1 Answer 1

1

The ampersand indicates what accelerator key the user can press in combination with Alt (or perhaps some other key like Cmd on Macs?) to click the button.

For example, if the label is "&Close", then pressing Alt-C will click the button.

If instead you want a literal ampersand in the label, repeat the ampersand twice: &&.

I don't think you can profitably set two labels to have the same accelerator key, e.g. "&Close" and "&Copy". Only the first label will react to Alt-C.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.