-
Notifications
You must be signed in to change notification settings - Fork 559
Description
Operating system: Windows 11, 64 bit
wxPython version & source: latest 4.3 snapshots, e.g. wxpython-4.3.0a16024+b2b09702-cp312-cp312-win_amd64.whl
Python version & source: stock 3.12 or 3.14
Description of the problem:
The wxWidgets 3.3 branch adds wxWindow->CreateAccessible() and wxWindow->GetOrCreateAccessible() to interface/wx/window.h.
With wxPython PR #2618 and PR #2515 wx.Window.GetOrCreateAccessible should call the virtual CreateAccessible to allow a Python class to provide an accessibility handler on demand by overriding this virtual method.
It seems that this is not working with the snapshot. Probably the C++ implementation of CreateAccessible is being called and this returns None.
With my own build of the current master branch, it's working fine. (I'm just using the standard commands python build.py dox etg --nodoc sip build).
The virtual method is only created in tweaker_tools.py if Windows is detected by
isWindows = sys.platform.startswith('win')
Could it be that this check does not work with the snapshot build process?
The output of the example code below:
With the snapshot build:
D:\Python\Python312-64_wx430>python AccessibleFrameMin.py
GetOrCreateAccessible(): None
The correct output with my own build (Visual Studio 2022):
D:\Python\Python312-64_wxgit>python AccessibleFrameMin.py
GetOrCreateAccessible(): <__main__.MyAcc object at 0x000002731643C9E0>
Code Example (click to expand)
import wx
class MyAcc(wx.Accessible):
pass
# this does override CreateAccessible to return a custom accessibility handler
class MyAccessibleTextCtrl(wx.TextCtrl):
def CreateAccessible(self):
return MyAcc(self)
class MainFrame(wx.Frame):
def __init__(self, parent, id=wx.ID_ANY, title=''):
wx.Frame.__init__(self, parent, id, title)
self.panel = wx.Panel(self, wx.ID_ANY)
self.text_ctrl = MyAccessibleTextCtrl(self.panel, wx.ID_ANY, "")
class MyApp(wx.App):
def OnInit(self):
self.frame = MainFrame(None, wx.ID_ANY, "")
self.SetTopWindow(self.frame)
self.frame.Show()
return True
# call GetOrCreateAccessible and print the result:
app = MyApp(0)
print("GetOrCreateAccessible():", app.frame.text_ctrl.GetOrCreateAccessible() )
app.MainLoop()