Ben Marks
Ben Marks

Reputation: 45

wxPython - wx.Button class

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' 

Upvotes: 1

Views: 114

Answers (1)

unutbu
unutbu

Reputation: 880887

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.

Upvotes: 1

Related Questions