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

NVDA Repeats Previous Line Instead of speeking "Blank" for Empty Lines in PyQt6 applications for QTextEdit and QPlainTextEdit widgets #17419

Open
snufas opened this issue Nov 19, 2024 · 14 comments
Labels
blocked/needs-external-fix component/qt Qt fraphical framework needs-technical-investigation A technical investigation is required to progress the issue. needs-triage

Comments

@snufas
Copy link

snufas commented Nov 19, 2024

I am trying to use pyQT6 and I'm testing out variety of widgets available and how accessible they are.
there is a problem how NVDA is reading. multi line text from
QTextEdit and QPlainTextEdit widgets in PyQt6 applications.

Steps to reproduce:

You can download the demo application source code that I made for demo purposes to properly investigate The problem.
text_viewer.txt
is a Python file just rename it. But I will illustrate the example anyways.

The problem is basically this, rather than reading "blank" for the emty line, it reads a previous line instead.
for example:
This is line 1

And this this line 2

it would be read like so
This is line 1
This is line 1
And this this line 2

Expected behavior:

it should be read like so:
This is line 1
" blank" spoken tekst for the new line
And this this line 2

Related Logs

Developer info for navigator object:
name: 'Text Viewer'
role: EDITABLETEXT
processID: 7200
roleText: None
states: FOCUSABLE, FOCUSED, READONLY
isFocusable: True
hasFocus: True
Python object: <NVDAObjects.Dynamic_EditableTextWithAutoSelectDetectionUIA object at 0x098A83F0>
Python class mro: (<class 'NVDAObjects.Dynamic_EditableTextWithAutoSelectDetectionUIA'>, <class 'NVDAObjects.behaviors.EditableTextWithAutoSelectDetection'>, <class 'NVDAObjects.behaviors.EditableText'>, <class 'NVDAObjects.behaviors.EditableTextWithSuggestions'>, <class 'NVDAObjects.behaviors.InputFieldWithSuggestions'>, <class 'NVDAObjects.behaviors.EditableTextBase'>, <class 'editableText.EditableText'>, <class 'NVDAObjects.UIA.UIA'>, <class 'NVDAObjects.window.Window'>, <class 'NVDAObjects.NVDAObject'>, <class 'documentBase.TextContainerObject'>, <class 'baseObject.ScriptableObject'>, <class 'baseObject.AutoPropertyObject'>, <class 'garbageHandler.TrackedObject'>, <class 'object'>)
description: ''
location: RectLTWH(left=109, top=157, width=582, height=334)
value: 'this is line 1\n\nand this this line 2'
TextInfo: <class 'NVDAObjects.UIA.UIATextInfo'>
appModule: AppModule(appModuleHandler, appName='python', processID=7200)
appModule.productName: 'Python'
appModule.productVersion: '3.9.13'
appModule.helperLocalBindingHandle: c_long(122649672)
appModule.appArchitecture: 'AMD64'
windowHandle: 594166
windowClassName: 'Qt670QWindowIcon'
windowControlID: 0
windowStyle: -1764818944
extendedWindowStyle: 256
windowThreadID: 23008
windowText: 'Accessible Text Viewer'
displayText: ''
UIAElement: <POINTER(IUIAutomationElement) ptr=0x4b5aec8 at 968ac60>
UIA automationID: 
UIA frameworkID: Qt
UIA runtimeID: (42, 594166, 4, -2147483645)
UIA providerDescription: [pid:7200,providerId:0x0 Main(parent link):Unidentified Provider (unmanaged:qwindows.dll)]
UIA className: QPlainTextEdit
UIA patterns available: TextPattern, LegacyIAccessiblePattern, ValuePattern, InvokePattern

System configuration

NVDA version:

2024.4 (NVDA is installed.)

Windows version:

10.0.19045 N/A Build 19045

Name and version of other software in use when reproducing the issue:

python 3.9
PyQt66.7.1 (the latest version as of this issue date.)

Other information about your system:

Microsoft Windows 10 Pro

Other questions

Does the issue still occur after restarting your computer?

Yesd

Have you tried any other versions of NVDA? If so, please report their behaviors.

No

If NVDA add-ons are disabled, is your problem still occurring?

Yes

Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?

Yes

My thoughts and comments

I'm not entirely sure if the problem lies with NVDA or the library itself. Other UI elements, like toolbars, buttons, and edit boxes, work fine.

Jaws has exactly the same behavior. That suggests it might be a problem with the library.

Nonetheless, NVDA needs to function properly with this widely used and important library.

As a side note, the Python WX library isn't great. I believe this issue needs attention because UI libraries are crucial for accessibility. This shouldn't be overlooked, as Python QT is a major library that requires full support.

I don't have the expertise to investigate this properly, but I'm hoping the developers do. Please include this issue in the milestones so I know it's a work in progress.

Thanks for grate work!!!

@Adriani90
Copy link
Collaborator

Related to #9376. There was PR #16568 trying to fix that one, but it was reverted in #17084 due to introduced regression.

@snufas
Copy link
Author

snufas commented Nov 19, 2024

@Adriani90

@snufas snufas closed this as completed Nov 19, 2024
@github-actions github-actions bot added this to the 2025.1 milestone Nov 19, 2024
@snufas snufas reopened this Nov 19, 2024
@snufas
Copy link
Author

snufas commented Nov 19, 2024

I managed to close the issue by accident... re opened all good.
@Adriani90 I checked the issue, it seems to be related with the Java, not Python, but regardless that needs to be looked at.

@CyrilleB79 CyrilleB79 removed this from the 2025.1 milestone Nov 19, 2024
@Emil-18
Copy link
Contributor

Emil-18 commented Nov 19, 2024

@snufas I think that is an issue with QT, and not NVDA. All other screen readers I have tested has that same problem. What is wrong with wx? To my knolage, wx is the most accessible python GUI library out there

@dmitrii-drobotov
Copy link
Contributor

Right, just to confirm, #9376 affects only apps using Java Access Bridge as the accessibility protocol, but from logs in the description I assume Qt uses UI Automation. So, while this is a separate issue, the cause may be very similar and related to the way Qt reports line bounds or how the _getLineOffsets method is implemented for UI Automation objects.

@snufas
Copy link
Author

snufas commented Nov 20, 2024

@Emil-18

@snufas snufas closed this as completed Nov 20, 2024
@github-actions github-actions bot added this to the 2025.1 milestone Nov 20, 2024
@snufas
Copy link
Author

snufas commented Nov 20, 2024

@Emil-18 It probably is QT issue, However, that needs to be confirmed by developers themselves. I can't report it because I don't know what exactly is the problem.
regarding wx
PyQt supports Microsoft's UIAutomation where as python wx does not. python wx Accessibility is based on old MSAA.

acording to chatgpt:
Microsoft Active Accessibility (MSAA) is an older technology developed by Microsoft to help software applications provide information about their user interface to assistive technologies, such as screen readers. It allows these technologies to interact with and retrieve information about UI elements, enabling users with disabilities to use applications more effectively.

Better API Framework:

  • UI Automation (UIA): This is the successor to MSAA and is generally considered a more modern and robust framework. UIA provides more detailed information and greater control over UI elements, making it more suitable for today's complex applications. It supports a wider range of UI elements and is designed to work across different Windows platforms.

In summary, while MSAA laid the groundwork for accessibility on Windows, UI Automation is the better choice for new applications due to its enhanced capabilities and support for modern UI elements.

@snufas snufas reopened this Nov 20, 2024
@snufas
Copy link
Author

snufas commented Nov 20, 2024

Alright, there is weird issue going on with me opening and closing the issue. There is some shortcut probably that I don't know. So, I'm gonna be very careful from now on. in providing the comments...
Generally speaking, I will repeat myself again that I think it's the NVDA who needs to report this because they can investigate exactly what the problem is.

@seanbudd seanbudd removed this from the 2025.1 milestone Nov 26, 2024
@seanbudd
Copy link
Member

@snufas - No please report this to the QT developers. You have a much better understanding of the problem as a reporter than we do.

@seanbudd seanbudd added blocked/needs-external-fix component/qt Qt fraphical framework needs-technical-investigation A technical investigation is required to progress the issue. needs-triage labels Nov 26, 2024
@snufas
Copy link
Author

snufas commented Nov 26, 2024

As I mentioned, I'm not fully familiar with the NVDA internals My knowledge of UIA accessibility is quite limited. I'm sure the developers at NV Access know more than I do, so they need to talk to each other and share the insights needed to fix the issue.

I would definitely report it if I knew exactly what was wrong. However, I can confirm that NVDA doesn't work correctly with QT applications. For example, while Narrator can always focus on QT windows and widgets, NVDA cannot.

Additionally, NVDA reads a message box more than once, while Narrator reads it only once. This shows that NVDA is doing something wrong, so we can't blame QT alone. NVDA isn't handling something correctly, unlike Narrator.

@seanbudd, @CyrilleB79 I see you contributing, which is great. Can you do more deep investigations? I can give you few basic pyQT applications to play with if you want.

@snufas snufas closed this as completed Nov 26, 2024
@github-actions github-actions bot added this to the 2025.1 milestone Nov 26, 2024
@snufas snufas reopened this Nov 26, 2024
@snufas
Copy link
Author

snufas commented Nov 26, 2024

Pardon me but I'm keep pressing Alt plus enter which is closing the issue GitHub shortcuts I forget about these...

As I mentioned, I'm not fully familiar with the NVDA internals My knowledge of UIA accessibility is quite limited. I'm sure the developers at NV Access know more than I do, so they need to talk to each other and share the insights needed to fix the issue.

I would definitely report it if I knew exactly what was wrong. However, I can confirm that NVDA doesn't work correctly with QT applications. For example, while Narrator can always focus on QT windows and widgets, NVDA cannot. I mean it does focus on the UI elements but not reliably.

Additionally, NVDA reads a message box more than once, while Narrator reads it only once. This shows that NVDA is doing something wrong, so we can't blame QT alone. NVDA isn't handling something correctly, unlike Narrator.

@seanbudd, @CyrilleB79 I see you contributing, which is great. Can you do more deep investigations? I can give you few basic pyQT applications to play with if you want.

@CyrilleB79 CyrilleB79 removed this from the 2025.1 milestone Nov 26, 2024
@CyrilleB79
Copy link
Collaborator

@snufas you do not need to know NVDA internals, nor to know the root cause of the issue.

What you have to report to QT is something like this:

  • I have this test application.
  • I do [describe what you do, e.g. navigate in the app].
  • I would expect [describe your expectations, e.g. NVDA speak once].
  • Instead I get [describe what happens, e.g. NVDA/Jaws speaks twice the same thing]

Do not forget to mention that it also happens with others screen readers.

@snufas
Copy link
Author

snufas commented Nov 26, 2024

@CyrilleB79 I get your point. I reported Variety of accessibility issues many times before. So I am aware how to do it well, Thank you for pointing things out.
The matter of fact I can literally paste the issue I described here in their forums somewhere. That's not a problem. I have no problems with pasting in things. It's more about the context... I thought someone could provide more details. evidently, that's not the case.

Alright then, I will report the issue to QT, However, in other situations clearly it's the fault of NVDA.
for example:
#12035 works as expected with narator. In summary, the issue describes that The content of the message box is repeated twice with NVDA, With JAWS for example, it's repeated three times. Whereas with narrator, it's only repeated once and works as expected.
#12476 is not even an issue anymore. works perfectly fine with NVDA when it has focus .

Ideally, all the existing QT bugs needs to be investigated from the NVDA-S perspective as well...
UI libraries gives or breaks accessibility so it needs to be high priority. Some issues exist for years and they haven't been checked or investigated. It seems.

I can't give out tu much because, I'm not contributing it yet. But that's why I create issues for someone who does contribute and can do a better job than I can do in terms of reporting and investigating.

it is easy to blame QT, not NVDA but the fact is that narrator in some situations behaves correctly where NVDA in jaws does not, so what does it tell you???

I leave the issue open for now, please don't close it. If I get any updates from the forum, I will paste them here. And if the issue gets resolved, I will close that issue myself. So we don't have the situation where some issues are not even existing anymore and they are still open. Or other way around.

@snufas
Copy link
Author

snufas commented Nov 26, 2024

@seanbudd, @CyrilleB79, @Adriani90
If either of you or someone else has anything to add regarding this specific issue, you can contribute here: Screen Reader Accessibility Issue on Windows: Repeats Previous Line Instead of Announcing 'Blank' for Empty Lines in PyQt6 QTextEdit and QPlainTextEdit Widgets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked/needs-external-fix component/qt Qt fraphical framework needs-technical-investigation A technical investigation is required to progress the issue. needs-triage
Projects
None yet
Development

No branches or pull requests

6 participants