We already know that accessibility on wxWidgets/wxPython is a bit sketchy and quirky overall (exhibit one, this very recent issue on the wxWidgets trac).
However, what I’m wondering right now is, specifically, how wx.Accessible is supposed to work - or if it works at all.
This class is meant to override/inject accessible info, into pretty much any gui element. The docs says, just derive and implement the functions, and you are good to go. Except, it doesn’t seem to work at all:
class MyAcc(wx.Accessible): # you must be on Windows to test this
def GetName(self, childid):
print('we hit wx.Accessible!')
return (wx.ACC_OK, 'this is an accessible name')
class MainFrame(wx.Frame):
def __init__(self, *a, **k):
wx.Frame.__init__(self, *a, **k)
p = wx.Panel(self)
self.widget = wx.TextCtrl(p, pos=(10, 10))
self.acc = MyAcc(self.widget) # or just MyAcc()?... doc isn't clear
self.widget.SetAccessible(self.acc)
wx.Button(p, pos=(10, 50)) # to let the focus change
app = wx.App()
MainFrame(None).Show()
app.MainLoop()
Even if you don’t want to test this code with a screen reader or the MS accessibility inspector, you can easily see that MyAcc just won’t work. Every time we clic on the TextCtrl, on WIndows the underlying MSAA framework is queried and should provide, among other things, our custom accessible name. Nothing happens instead, as MyAcc.GetName is never called (we never get to see the printed message on the console output).
Moreover, I’m having a very hard time to find even a single example with wx.Accessible online. And I mean, not just wxPython stuff. There’s not even a test case in the wxWidgets test suite.
Even the accessibility demo in wxWidget, that is supposed to showcase this feature, never makes direct use of wxAccessible. It uses instead the (undocumented!) subclass wxWindowAccessible, which is not ported into wxPython.
So, I guess, my questions are…
is there any wxPython-specific issue with wx.Accessible?
maybe porting wx.WindowAccessible too could be worth the shot?
has anyone ever given this whole accessible thing a try?
I know this is a rather niche topic, but thanks in advance for any feedback…
riccardo-