wx.html2.WebView accessibility with screen readers

_Abdel_ <[email protected]> Wed, 27 Mar 2019 13:13:53 +0100
Newsgroups gmane.comp.python.wxpython.devel
Message-ID <[email protected]>
Hi,

In wxPython 4.0 Phoenix, I'm trying to use wx.html2.WebView with a 
screen reader.

Whether with JAWS or NVDA, I have to make a left mouse click on the 
WebView to be able to see my page in an accessible Web interface, 
('Internet Explorer_Server').

Here is my code using the SetPage method, but know that I'm having the 
same problem with LoadURL.

You'll find in attachment, an other code that uses the 
user32.mouse_event to simulate the left click once the WevView is displayed.

This attached code works perfectly, but it would be better if the 
Internet Explorer_Server page is opened without having to make this 
click, would it be possible to integrate this into a method of the 
wx.html2.WevView class?

Thank you in advance for your answers.

import wx
import wx.html2

class MyWebView (wx.Dialog):

     def __init__(self, parent):
         wx.Dialog.__init__(self, parent)
         sizer = wx.BoxSizer(wx.VERTICAL)
         self.browser = wx.html2.WebView.New(self)
         self.changeBtn = wx.Button (self, -1, label="Change page")

         # The pages that I want to display disposed in a tuple.
         self.pages = (
         "<html><head><title>Hello everyone 
!</title></head><body><h1>We're testing wx.html2.WebView with a Screen 
Reader !</h1></body></html>",
         "<html><head><title>Second page !</title></head><body><h1>This 
is a second page</h1></body></html>",
         "<html><head><title>Third page !</title></head><body><h1>This 
is a third page</h1></body></html>"
         )

         self.index = 0
         self.display = self.pages[self.index]
         sizer.Add(self.browser, 1, wx.EXPAND, 10)
         sizer.Add(self.changeBtn)
         self.SetSizer(sizer)
         self.SetSize((700, 700))

     # Events.
         self.changeBtn.Bind (wx.EVT_BUTTON, self.onChangePage)

     def onChangePage (self, evt):
         self.index += 1
         if self.index == len (self.pages):
             self.index = 0
         self.display = self.pages[self.index]
         self.browser.SetPage(self.display, "")

if __name__ == '__main__':
     app = wx.App()
     dialog = MyWebView (None)
     dialog.browser.SetPage(dialog.display, "")
     dialog.Show ()
     app.MainLoop()

Kind regards,
Abdel.

-- 
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
testHtml2WebView.py (text/plain, 1.8 KB)
import wx
import wx.html2
import ctypes

# Using user32 to simulate the click.
user32 = ctypes.windll.user32

class MyWebView (wx.Dialog):

    def __init__(self, parent):
        wx.Dialog.__init__(self, parent)
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.browser = wx.html2.WebView.New(self)
        self.changeBtn = wx.Button (self, -1, label="Change page")

        # The pages that I want to display disposed in a tuple.
        self.pages = (
        "<html><head><title>Hello everyone !</title></head><body><h1>We're testing wx.html2.WebView with a Screen Reader !</h1></body></html>",
        "<html><head><title>Second page !</title></head><body><h1>This is a second page</h1></body></html>",
        "<html><head><title>Third page !</title></head><body><h1>This is a third page</h1></body></html>"
        )

        self.index = 0
        self.display = self.pages[self.index]
        sizer.Add(self.browser, 1, wx.EXPAND, 10)
        sizer.Add(self.changeBtn)
        self.SetSizer(sizer)
        self.SetSize((700, 700))
        # To get the X and Y positions of the Widget.
        self.point = self.GetPosition()

        # Events.
        self.changeBtn.Bind (wx.EVT_BUTTON, self.onChangePage)

    def onChangePage (self, evt):
        self.index += 1
        if self.index == len (self.pages):
            self.index = 0
        self.display = self.pages[self.index]
        self.browser.SetPage(self.display, "")

if __name__ == '__main__':
    app = wx.App()
    dialog = MyWebView (None)
    dialog.browser.SetPage(dialog.display, "")
    dialog.Show ()
    # Moving the mouse cursor and simulating the click.
    user32.SetCursorPos (dialog.point.x+350, dialog.point.y+350)
    user32.mouse_event(2, 0, 0, None, None)
    #user32.mouse_event(4, 0, 0, None, None)
    app.MainLoop()