How to associate a StaticText mnemonic with the right widget

Here’s some code I have:

self.sectionLabel = wx.StaticText(self.panel, label='Se&ction')
self.sectionChoice = wx.Choice(self.panel)
self.librariesCheckbox = wx.CheckBox(self.panel, label='Include &Libraries')

When I press Alt+L the checkbox correctly toggles.
But when I press Alt+C instead of the focus going to the Choice it also toggles the checkbox.

How can I force the sectionLabel’s mnemonic to be associated with the sectionChoice?

In Qt there’s a concept of “buddy” where a label’s buddy is the widget to give the focus to when the label’s mnemonic is pressed. Is there a wx equivalent?

I don’t think that this is available out of the box.
wx uses the native widgets and IIRC StaticText is not even a widget on some platforms but just painted text. Key navigation is handled by the native widgets. Therefore you need e.g. a panel inside a frame to have Tab-navigation on Windows. Qt on the other hand does everything itself and so it looks and behaves the same on every supported platform. Both approaches have advantages and disadvantages.

Your suggested handling of the Alt key would not be 100% consistent anyway, as Alt+L is an action while Alt+C would be a focus change only.

You can always implement a key handler yourself. Often this is the best approach.

Some snippets:

self.Bind(wx.EVT_CHAR_HOOK, self.on_char_hook)

event.GetKeyCode()
event.ControlDown()
event.ShiftDown()
event.AltDown()

event.GetEventObject()

event.GetEventObject().GetNextSibling()
widget.SetFocus()

event.Skip()

Thank you. I used wx.EVT_CHAR_HOOK as you suggested and now I have the behaviour I want.