Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Mu editor application accessible for blind or visually impaired users #2530

Open
FrancoisLB opened this issue Nov 18, 2024 · 0 comments

Comments

@FrancoisLB
Copy link

Mu editor is not fully accessible for blind or visually impaired users with screen reader (on windows with NVDA free and open source screen reader).

some shortcuts are missing ot access main widow icons.

also, to make it accessible some rules have to be followed under pyQT5

To make a PyQt5 application accessible for blind or visually impaired users who use a screen reader like NVDA, follow these key steps:


1. Use Standard Accessible Widgets

PyQt5 supports accessibility via standard accessibility APIs (such as UI Automation on Windows). Widgets like QPushButton, QLineEdit, and QLabel are typically accessible by default. Use these standard widgets whenever possible.


2. Set Accessible Descriptions

Provide accessible information by using the accessibleName and accessibleDescription properties of widgets. These allow the screen reader to announce meaningful information about the interface elements.

Example:

from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton

app = QApplication([])
window = QMainWindow()

button = QPushButton("Click here", window)
button.setAccessibleName("Main button")
button.setAccessibleDescription("This button submits the form data.")
button.setGeometry(100, 100, 200, 50)

window.show()
app.exec_()

3. Link Labels to Form Fields

Use widgets like QLabel to provide context to form fields and associate them with setBuddy().

Example:

from PyQt5.QtWidgets import QApplication, QMainWindow, QLineEdit, QLabel, QVBoxLayout, QWidget

app = QApplication([])
window = QMainWindow()
central_widget = QWidget()
layout = QVBoxLayout(central_widget)

label = QLabel("Name:", central_widget)
edit = QLineEdit(central_widget)
label.setBuddy(edit)  # Links the label to the input field

layout.addWidget(label)
layout.addWidget(edit)
window.setCentralWidget(central_widget)

window.show()
app.exec_()

4. Add Keyboard Shortcuts

Provide keyboard shortcuts to allow navigation without using a mouse. For instance, use setShortcut() to link actions to keyboard keys.

Example:

button.setShortcut("Ctrl+S")  # Activate the button with Ctrl + S

5. Explicitly Enable Accessibility (if Needed)

On some platforms, you may need to explicitly enable accessibility with PyQt5. Use the QAccessible module for this purpose.

Example:

from PyQt5.QtGui import QAccessible

QAccessible.installFactory(QAccessible.defaultFactory())

6. Test with NVDA

Download and install NVDA (if not already installed), and test your application by navigating with the keyboard while listening to the feedback.

  • Ensure elements are announced with meaningful descriptions.
  • Verify that Tab, Shift+Tab, and arrow key navigation work correctly.

7. Use PyQt5 Tools for Advanced Accessibility

If creating custom widgets, define an accessible role by implementing a QAccessibleInterface.

Example for a custom widget:

from PyQt5.QtWidgets import QWidget
from PyQt5.QtGui import QAccessible, QAccessibleInterface

class MyCustomWidget(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)

    def accessibleRole(self):
        return QAccessible.Button  # Declare this widget as a button

8. Provide Documentation and Gather Feedback

Include clear documentation to guide users on how to use your application with a screen reader. Solicit feedback from visually impaired users to improve accessibility.


By following these steps, your application should be accessible and navigable for users relying on a screen reader like NVDA.

many thanks by advance, best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant