Python / Qt: Misbehaviour of screen reader compatibility in Ubuntu 22.04
-
Hello,
Virtualbox 6.1.36
Ubuntu 22.04
Python 3.10.4
Qt6I set the AccessibleDescription property on all controls:
self.setAccessibleDescription("Programmfenster für PyQt6 Telefonnummer-Verwaltung") self.lbl_schriftgroessen.setAccessibleDescription('Beschriftung für Aufklappbare Liste Schriftgröße') self.cbxschriftgroesse.setAccessibleDescription('Auswahlliste für Schriftgröße') self.lbl_vorname.setAccessibleDescription('Beschriftung für Eingabefeld Vorname') self.edt_nachname.setAccessibleDescription('Eingabefeld für Nachname') self.lbl_nachname.setAccessibleDescription('Beschriftung für Eingabefeld Nachname') self.edt_telefonnummer.setAccessibleDescription('Eingabefeld fürTelefonnmummer')
...
I start the screen reader Orca.
After that I start my Python Qt application.
Now I operate my Python Qt application with the tab key.
The Orca screen reader remains silent.
When the first widget gets focus the second time,
the Orca screen reader suddenly reads the text from the property
AccessibleDescription.Question:
What can be the reason? -
Hi,
Do you have the same issue with PySide2 ?
-
I have never programmed graphical user interfaces with PySide2. That's why I can't answer your question.
-
What are you using for your current application ?
-
from PyQt6 import QtGui, QtWidgets from PyQt6.QtGui import QGuiApplication, QIcon from PyQt6.QtWidgets import QWidget, QApplication, QLabel, QComboBox, QLineEdit, QPushButton, QFormLayout from PyQt6.QtCore import *
-
Then, can you try with PyQt5 ?
From the looks of your imports, you can simply replace the 6 by 5 once PyQt5 installed.
-
@SGaist said in Python / Qt: Misbehaviour of screen reader compatibility in Ubuntu 22.04:
PyQt5
Thank you for your idea! Unfortunately, the same misbehavior is with PyQt5.here some code in Ubuntu:
self.edt_nachname = QLineEdit(self) self.edt_nachname.setStyleSheet('font-size: 20px') self.edt_nachname.setAccessibleName('Bitte Nachname eingeben') self.edt_nachname.setAccessibleDescription('Eingabefeld für Nachname') self.edt_nachname.setToolTip('Bitte Nachname eingeben')
I've been trying to see if using setToolTip helps.
-
I tried to freshly install the screen reader Orca: https://forum.qt.io/topic/138941/python-qt-misbehaviour-of-screen-reader-compatibility-in-ubuntu-22-04/7 . Unfortunately it didn't solve my problem either.
-
How did you install orca ?
-
Orca is preinstalled. Sometimes you have to install it in the terminal. I do it like this: sudo apt install orca
-
I tried it with PySide6:
import sys from PySide6 import QtGui, QtWidgets from PySide6.QtGui import QGuiApplication from PySide6.QtWidgets import QWidget, QApplication, QLabel, QComboBox, QLineEdit, QPushButton, QFormLayout from PySide6.QtCore import * import csv
The same wrongdoing!
-
Sorry for the very late reply, I tested PySide6 version 6..4.3 (installed using pip in a dedicated environment) on KDE Neon (which is based on Ubuntu 22.04 at this time) and orca 42.0-1ubuntu2 and it worked with the following test script:
import sys from PySide6.QtCore import Qt from PySide6.QtWidgets import QApplication from PySide6.QtWidgets import QHBoxLayout from PySide6.QtWidgets import QLabel from PySide6.QtWidgets import QPushButton from PySide6.QtWidgets import QWidget if __name__ == "__main__": app = QApplication(sys.argv) widget = QWidget() widget.setAccessibleDescription("This is a test") label = QLabel("Test") label.setTextInteractionFlags(Qt.TextSelectableByMouse|Qt.TextSelectableByKeyboard) button = QPushButton("Test button") button.setAccessibleDescription("This is a button") button2 = QPushButton("Test button 2") button2.setAccessibleDescription("This is a second button") button2.clicked.connect(lambda: label.setText("New text")) layout = QHBoxLayout(widget) layout.addWidget(label) layout.addWidget(button) layout.addWidget(button2) widget.show() sys.exit(app.exec())
Note that I started orca on the command line and the script from another one.
Note that something seems of with the QLabel. It seems not listed along the buttons however if you click on it then orca will say its content.