@SGaist said in Accessibility Issue with Radio Buttons in PyQt6 Setting:
Testing with PySide6 allows to check whether it's a binding specific or a possibly Qt specific issue.
As for whether the PyQt folks work on this, you should as Riverbank Computing as they are the authors of that binding.
Hi,
I tested the same example using PySide6, and unfortunately, the focus issue remains the same. When navigating to the group of radio buttons, the screen reader still places its focus on the first button in the group instead of the selected option.
This confirms that the problem is not specific to PyQt6 but seems to be a broader issue with how focus is handled in such scenarios.
Looking forward to any suggestions or insights you might have.
Thank you!
import sys
from PySide6.QtCore import Qt
from PySide6.QtGui import QPalette, QColor
from PySide6.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QRadioButton, QPushButton, QWidget, QButtonGroup
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
# Set dark theme
self.set_dark_theme()
# Create layout and central widget
layout = QVBoxLayout()
# Add example buttons before the radio buttons
button1 = QPushButton("Button 1")
button2 = QPushButton("Button 2")
layout.addWidget(button1)
layout.addWidget(button2)
# Create radio buttons
self.radio_enable = QRadioButton("Enable")
self.radio_disable = QRadioButton("Disable")
self.radio_default = QRadioButton("Default")
# Set the "Default" option selected by default
self.radio_default.setChecked(True)
# Group the radio buttons for accessibility
self.radio_group = QButtonGroup()
self.radio_group.addButton(self.radio_enable)
self.radio_group.addButton(self.radio_disable)
self.radio_group.addButton(self.radio_default)
# Add radio buttons to the layout
layout.addWidget(self.radio_enable)
layout.addWidget(self.radio_disable)
layout.addWidget(self.radio_default)
# Set the central widget and layout
container = QWidget()
container.setLayout(layout)
self.setCentralWidget(container)
self.setWindowTitle("PySide6 Accessibility Example")
def set_dark_theme(self):
palette = QPalette()
palette.setColor(QPalette.ColorRole.Window, QColor(53, 53, 53))
palette.setColor(QPalette.ColorRole.WindowText, Qt.GlobalColor.white)
palette.setColor(QPalette.ColorRole.Base, QColor(35, 35, 35))
palette.setColor(QPalette.ColorRole.AlternateBase, QColor(53, 53, 53))
palette.setColor(QPalette.ColorRole.ToolTipBase, Qt.GlobalColor.white)
palette.setColor(QPalette.ColorRole.ToolTipText, Qt.GlobalColor.white)
palette.setColor(QPalette.ColorRole.Text, Qt.GlobalColor.white)
palette.setColor(QPalette.ColorRole.Button, QColor(53, 53, 53))
palette.setColor(QPalette.ColorRole.ButtonText, Qt.GlobalColor.white)
palette.setColor(QPalette.ColorRole.BrightText, Qt.GlobalColor.red)
palette.setColor(QPalette.ColorRole.Link, QColor(42, 130, 218))
palette.setColor(QPalette.ColorRole.Highlight, QColor(42, 130, 218))
palette.setColor(QPalette.ColorRole.HighlightedText, Qt.GlobalColor.black)
self.setPalette(palette)
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec())