In Python 3.10.5 on Windows 11 using the wxPython 4.2.0 package, I am trying to create a labelled wx.ListCtrl widget, where the widget label would be recognised by screen readers, but I cannot find the way to do so. So far, I have the following code:
hbox = wx.BoxSizer(wx.HORIZONTAL)
label = wx.StaticText(self.panel, wx.ID_ANY, 'My label')
hbox.Add(label, 1, wx.EXPAND | wx.ALIGN_LEFT | wx.ALL, 5)
list = wx.ListCtrl(self.panel, wx.ID_ANY)
hbox.Add(list, 1, wx.EXPAND | wx.ALIGN_LEFT | wx.ALL, 5)
If I use the code above, both the label and list are created, but they seem not to be tied together, as when the list widget is focused, screen reader narrates only "List view", ignoring the label. However, if in the same code I replace wx.ListCtrl with wx.ListBox, the label starts to be narrated without an issue. But I need to use wxListCtrl, not wx.Listbox.
How can I label the wx.ListCtrl widget properly from the accessibility perspective, so that when focused with the screen reader, the label for the widget would be narrated?