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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tkinter_a11y_lint-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tkinter_a11y_lint-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7df24651e2bd5f22ac596aeee557c4676c4323ef985054c01ad1c26b54159fcb
|
|
| MD5 |
26c4657c52d98b047a598b8420d344c6
|
|
| BLAKE2b-256 |
f11f5682c1dbe1835d6d94614fc2e7315c9e57b4dde43032da31ae95f7c1abce
|