Re: rebuilding wx widgets with accessible addons

Nathan smith <[email protected]> Tue, 19 Nov 2024 17:52:40 +0000
Newsgroups gmane.comp.python.wxpython
Message-ID <[email protected]>
Dietmar


Can't thank you enough.

While the StaticLabel mention was a bust (I'd tried that already as=20
that's how I used to do things years ago), something about either the=20
way you wrote, or the git hub post, had me going down the route of=20
wx.Accessible, and writing this:


class AccessibleSlider(wx.Accessible):
 =C2=A0=C2=A0=C2=A0 def __init__(self, widget, name=3D"Custom Widget"):
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 super().__init__()
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 self.widget =3D widget
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 self.name =3D name

 =C2=A0=C2=A0=C2=A0 def GetName(self, childId):
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 """Return the accessible name."=
""
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return (wx.ACC_OK, self.name)

 =C2=A0=C2=A0=C2=A0 def GetValue(self, childId):
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 """Return the accessible value.=
"""
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return (wx.ACC_OK, str(self.wid=
get.GetValue()))

 =C2=A0=C2=A0=C2=A0 def GetRole(self, childId):
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 """Return the accessible role (=
e.g., slider, button)."""
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return (wx.ACC_OK, wx.ROLE_SYST=
EM_SLIDER)

 =C2=A0=C2=A0=C2=A0 #def GetDescription(self, childId):
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #"""Return an additional descri=
ption."""
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #return (wx.ACC_OK, "This is a =
custom accessible slider.")


Low and behold, sld.SetAccessible witht that, we have a gorgious slider=20
label.

I've commented out get description because it read that description out=20
every time and it got massively annoying very fast.

Combine that with using SetLabel on wx.listctrl, sticking to SetName for=20
wx.textctrl and I think. *think* I'm there! A happy upgrade.


Goign to feel weird running a modern wx python version for the firs=20
ttime in years :)


Course, this is where you mention wx.Accessible is being removed in the=20
next pull request :)


Thanks for sticking with me, and don't hesitate to let me know if you=20
want me to try something else.

Nathan

On 18/11/2024 23:02, Dietmar Schwertberger wrote:
> P.S.: For slider, the name should be displayed if you create a=20
> StaticText as label right before creating the wxSlider.
>

--=20
You received this message because you are subscribed to the Google Groups "=
wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/wxpython-us=
ers/cdd3de0c-dfb3-4d3f-8484-a80a6c564eaf%40gmail.com.