[program-l] Re: Question about accessibility in wxPython

  • From: Meisam Amini <meisamamini21@xxxxxxxxx>
  • To: program-l@xxxxxxxxxxxxx
  • Date: Sat, 5 Oct 2019 20:45:09 +0330

Quentin, thanks for the help, but the order thing doesn't work for me. I
have Windows 10 and the small test script I wrote doesn't work accessibly
neither with NVDA nor with JAWS. I paste the code I wrote here and also
attach it to this email. Maybe I have done something wrong.

import wx

class Frame(wx.Frame):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
pnl = wx.Panel(self)
box = wx.BoxSizer(wx.HORIZONTAL)
innerBox1 = wx.BoxSizer(wx.VERTICAL)
stUserName = wx.StaticText(pnl, label="User name")
tcUserName = wx.TextCtrl(pnl)
innerBox1.Add(stUserName)
innerBox1.Add(tcUserName)
innerBox2 = wx.BoxSizer(wx.VERTICAL)
stPassword = wx.StaticText(pnl, label="Password")
tcPassword = wx.TextCtrl(pnl)
innerBox2.Add(stPassword)
innerBox2.Add(tcPassword)
box.Add(innerBox1)
box.Add(innerBox2)
pnl.SetSizer(box)

def main():
a=wx.App()
f=Frame(None, title="Sample", name="Sample")
f.Show()
a.MainLoop()

if __name__ == "__main__":
main()

On Sat, Oct 5, 2019 at 6:36 PM Jordy Deweer <jordyydeweer@xxxxxxxxx> wrote:

Hey Quentin



If you can provide a small working example (I lack the time to do it
quickly myself), I would be happy to test it out on a MacBook.



Greetings, Jordy





Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
Windows 10



*From: *QuentinC <quentinc@xxxxxxxxxxx>
*Sent: *Saturday, October 5, 2019 3:44 PM
*To: *program-l@xxxxxxxxxxxxx
*Subject: *[program-l] Re: Question about accessibility in wxPython



Hello,



Something that works well on windows (and anyway you don't have anything

else) is to make sure to create your controls in the right order.



First the static text label, then immediately after, the associated

control. No other control in between.

Only the order of creation is important. Their place on screen or sizer

settings have no importance.

You may customize accessibility stuff by using wxAccessible, but it's

quite complicated if you want to do it well. So better stay out of it.

Just create your controls in the right order and you have nothing else

to do.



Always creating controls in a well defined order also implicitely

establish the tab traversal in that same order.

IN a wxDialog, you then have nothing else special to do to have tab

working fine. IN wxFrame it works better if all controls are put in a

wxPanel rather than directly in the wxFrame.



So for example, if you have a login dialog box, you should create the

controls in that order:

1. wxStaticText "Username:"

2. wxTextCtrl for the username field

3. wxStaticText "Password:"

4. wxTextCtrl for the password

5. wxCheckboxCtrl for remember me

6. wxButton for OK

7. wxButton for Cancel



Note that checkboxes, radios and buttons don't need a static text label,

because they contin themselves and alone the text read by Jaws/NVDA.



Sadly, I don't knwo at all if  it's so easy in other platforms. No one

has been able to reply for mac so far, in particular.



Hopes that helps

** To leave the list, click on the immediately-following link:-

** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]

** If this link doesn't work then send a message to:

** program-l-request@xxxxxxxxxxxxx

** and in the Subject line type

** unsubscribe

** For other list commands such as vacation mode, click on the

** immediately-following link:-

** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]

** or send a message, to

** program-l-request@xxxxxxxxxxxxx with the Subject:- faq



import wx

class Frame(wx.Frame):
        def __init__(self, *args, **kwargs):
                super().__init__(*args, **kwargs)
                pnl = wx.Panel(self)
                box = wx.BoxSizer(wx.HORIZONTAL)
                innerBox1 = wx.BoxSizer(wx.VERTICAL)
                stUserName = wx.StaticText(pnl, label="User name")
                tcUserName = wx.TextCtrl(pnl)
                innerBox1.Add(stUserName)
                innerBox1.Add(tcUserName)
                innerBox2 = wx.BoxSizer(wx.VERTICAL)
                stPassword = wx.StaticText(pnl, label="Password")
                tcPassword = wx.TextCtrl(pnl)
                innerBox2.Add(stPassword)
                innerBox2.Add(tcPassword)
                box.Add(innerBox1)
                box.Add(innerBox2)
                pnl.SetSizer(box)

def main():
        a=wx.App()
        f=Frame(None, title="Sample", name="Sample")
        f.Show()
        a.MainLoop()

if __name__ == "__main__":
        main()

Other related posts: