Support CreateAccessible in all wxWindow subclasses#2874
Support CreateAccessible in all wxWindow subclasses#2874swt2c merged 1 commit intowxWidgets:masterfrom
Conversation
In order to do this, had to provide a C++ implementation of CreateAccessible in all classes, and make wxAccessible visible in all modules. This was previously done in 5279c3c by Dietmar, but this didn't work in our CI system where the sdist is built on a Linux system.
|
Hey @DietmarSchwertberger, I think this should finally resolve the issue with |
|
I have just downloaded |
|
This change hasn't been merged yet, so isn't in a snapshot build yet. I'll go ahead and merge it now. |
|
I did download |
|
Oh. That version didn't make sense as being from the PR, that's why I thought you had downloaded from the snapshot builds server. However, I noticed you mentioned Do you have a code snippet you can share, so I can make sure it works? Not that I'll be able to test it, but just wanting to see how it is supposed to work. |
|
Never mind about the code snippet. I see you provided that in one of the linked issues. I need to double check but it is possible my solution might not work in this case. Need to see compare the generated code with what gets generated just when you add a virtual method. |
|
Thanks for your support. Yes, it's two steps: sip_corewxWindow.cpp looks reasonable, IMHO, but means that on wxPython now wxAccessible * _wxWindow_GetOrCreateAccessible(wxWindow* self)
{
#if wxUSE_ACCESSIBILITY
return self->GetOrCreateAccessible();
#else
wxPyRaiseNotImplemented();
return NULL;
#endif
}When I install the current snapshot on Windows: >>> import wx
>>> wx.VERSION
(4, 3, 0, 'a16051+1a5e2cf2')
>>> app = wx.App()
>>> frame = wx.Frame()
>>> frame.GetOrCreateAccessible()
>>>That means it was compiled with On Ubuntu, a build from the master branch shows that both methods are there, while previously the build would not have had them: >>> import wx
>>> wx.VERSION
(4, 3, 0, 'a1')
>>> app = wx.App()
>>> frame = wx.Frame()
>>> frame.GetOrCreateAccessible()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NotImplementedError
>>> frame.CreateAccessible()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NotImplementedErrorFor comparison, an old version on Ubuntu, where >>> import wx
>>> wx.VERSION
(4, 2, 1, '')
>>> app = wx.App()
>>> frame = wx.Frame()
>>> frame.GetOrCreateAccessible()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Frame' object has no attribute 'GetOrCreateAccessible'So, to summarize: contrary to wxWidgets, we now always have both methods, no matter whether >>> wx.USE_ACCESSIBILITY
1The problem is that May initial approach from https://github.com/wxWidgets/Phoenix/pull/2618/changes was this change to if isWindows:
# does not compile on GTK and macOS.
publicWindowVirtuals.append( ('CreateAccessible', 'wxAccessible* CreateAccessible()') )Now we have if klass.name not in ['wxWindow', 'wxProgressDialog', 'wxRichTextCtrl']:
klass.addCppMethod('wxAccessible*', 'CreateAccessible', '()', """\
#if wxUSE_ACCESSIBILITY
return self->CreateAccessible();
#else
wxPyRaiseNotImplemented();
return NULL;
#endif
""", factory=True)I don't see where this creates the virtuality, but I'm not a C++ guy. I will only be online after Easter again. Happy Easter! |
In order to do this, had to provide a C++ implementation of CreateAccessible in all classes, and make wxAccessible visible in all modules. This was previously done in 5279c3c by Dietmar, but this didn't work in our CI system where the sdist is built on a Linux system.
Fixes #2851.