[PyQt] PyQt5.5 some example for accessibility testing

germano carella germanocarella.list at gmail.com
Sun Sep 20 09:55:50 BST 2015


Hi to all,
I written an example for accessibility testing on PyQt5.5.
The app is very stupid, it shows 2 QLineEdit, a QCombobox and 2 
QPushbuttons.
My screen reader recognizes controls as edit boxes, button also are 
recognized as an edit box.
When I try to write something It doesn't read anything.
If I press arrow keys, text written is not spoken.
In combobox, items are not spoken.

I paste the example I written.

Maybe I must rebuild PyQt5 with accessibility support enabled? How can I 
do this?

from PyQt5 import Qt,QtCore,QtGui
import sys

class MainWindow(Qt.QWidget):
     def __init__(self):
         super(MainWindow,self).__init__()
         GridLayout = Qt.QGridLayout()
         FirstNameLabel = Qt.QLabel("First Name: ")
         FirstNameText = Qt.QLineEdit()
         FirstNameLabel.setBuddy(FirstNameText)
         LastName = Qt.QLabel("Last Name: ")
         LastNameText = Qt.QLineEdit()
         LastName.setBuddy(LastNameText)
         Sex = Qt.QLabel("Sex: ")
         SexChoice = Qt.QComboBox()
         SexChoice.addItem("Male")
         SexChoice.addItem("Female")
         Sex.setBuddy(SexChoice)
         SaveBtn = Qt.QPushButton("Save")
         CancelBtn=Qt.QPushButton("Cancel")
         GridLayout.addWidget(FirstNameLabel,0,0)
         GridLayout.addWidget(FirstNameText,0,1)
         GridLayout.addWidget(LastName,1,0)
         GridLayout.addWidget(LastNameText,1,1)
         GridLayout.addWidget(Sex,2,0)
         GridLayout.addWidget(SexChoice,2,1)
         GridLayout.addWidget(SaveBtn,3,0)
         GridLayout.addWidget(CancelBtn,3,1)

         self.setLayout(GridLayout)
         self.setWindowTitle("Address Book")

if __name__=='__main__':
     app = Qt.QApplication(sys.argv)
     mw = MainWindow()
     mw.show()
     app.exec_()

Germano


More information about the PyQt mailing list