Skip to main content

A pylint plugin for tkinter accessibility linting

Project description

Tkinter Accessibility Lint Plugin

A pylint plugin that inspects tkinter usage in Python to enforce accessibility best practices.

Features

This plugin provides the following accessibility checks for tkinter applications:

  • UI elements should have text attributes - Ensures that UI elements like buttons, labels, and entries have appropriate text content for screen readers
  • UI controls should have tab index assignment - Verifies that interactive controls have proper tab order for keyboard navigation

Installation

pip install tkinter-a11y-lint

Or install from source:

git clone https://github.com/yourusername/tkinter-a11y-lint.git
cd tkinter-a11y-lint
pip install -e .

Usage

Command Line

Run pylint with the plugin enabled:

pylint --load-plugins=tkinter_a11y_lint.plugin your_tkinter_app.py

Configuration File

Add to your .pylintrc file:

[MASTER]
load-plugins=tkinter_a11y_lint.plugin

Error Codes

Code Message Description
C9001 missing-text-attribute UI element should have text attribute for accessibility
C9002 missing-tab-index Interactive UI control should have tab index assignment

Examples

Missing Text Attribute (C9001)

import tkinter as tk

root = tk.Tk()
# Bad: Button without text
button = tk.Button(root)  # Will trigger C9001

# Good: Button with text
button = tk.Button(root, text="Click me")

Missing Tab Index (C9002)

import tkinter as tk

root = tk.Tk()
# Bad: Entry without tab index
entry = tk.Entry(root)  # Will trigger C9002

# Good: Entry with tab index
entry = tk.Entry(root)
entry.configure(takefocus=True)
# or
entry = tk.Entry(root, takefocus=True)

Development

Setup Development Environment

git clone https://github.com/yourusername/tkinter-a11y-lint.git
cd tkinter-a11y-lint
pip install -e ".[dev]"

Running Tests

pytest

Code Formatting

black tkinter_a11y_lint/

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tkinter_a11y_lint-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file tkinter_a11y_lint-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tkinter_a11y_lint-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7df24651e2bd5f22ac596aeee557c4676c4323ef985054c01ad1c26b54159fcb
MD5 26c4657c52d98b047a598b8420d344c6
BLAKE2b-256 f11f5682c1dbe1835d6d94614fc2e7315c9e57b4dde43032da31ae95f7c1abce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page