Loading...
Loading...
Python and wxPython development reference patterns, common pitfalls, framework-specific guides, desktop accessibility APIs, and cross-platform considerations. Use when building, debugging, packaging, or reviewing Python desktop applications.
npx skill4agent add community-access/accessibility-agents python-development| Version | Key Features | EOL |
|---|---|---|
| 3.10 | | Oct 2026 |
| 3.11 | Exception groups, | Oct 2027 |
| 3.12 | Type parameter syntax | Oct 2028 |
| 3.13 | Experimental free-threaded mode, improved error messages | Oct 2029 |
| 3.14 | | Oct 2030 |
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "my-app"
version = "1.0.0"
requires-python = ">=3.10"
dependencies = []
[project.optional-dependencies]
dev = ["pytest>=8.0", "ruff>=0.6", "mypy>=1.11"]
[project.scripts]
myapp = "my_app.__main__:main"
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-ra --strict-markers"
[tool.ruff]
target-version = "py310"
line-length = 100
[tool.ruff.lint]
select = ["E", "F", "W", "I", "N", "UP", "B", "SIM", "TCH"]
[tool.mypy]
python_version = "3.10"
strict = trueexe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, a.datas,
name='MyApp', console=False, icon='icon.ico')exe = EXE(pyz, a.scripts, exclude_binaries=True,
name='MyApp', console=False, icon='icon.ico')
coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, name='MyApp')pkg_resources.externaccessible_output2keyring.backendsplatformdirshttpx._transportshttpcore._backendsencodings| Sizer | When to Use |
|---|---|
| Stack items top-to-bottom |
| Lay items left-to-right |
| Form layouts with labels + controls |
| Even grid layouts |
| Flow layout that wraps |
| Grouped controls with border |
# From worker thread:
wx.CallAfter(self.update_status, "Done")
wx.PostEvent(self, CustomEvent(data=result))
# NEVER do this from a worker thread:
self.status_bar.SetStatusText("Done") # CRASH or CORRUPTION| ID | Purpose |
|---|---|
| OK button |
| Cancel button |
| Save action |
| Open action |
| Exit / Quit |
| Help action |
| New document |
| Undo / Redo |
| Event | Trigger |
|---|---|
| Button click |
| Menu item selected |
| Window close requested |
| Window resized |
| Timer fired |
| Text control content changed |
| List item selected |
| Tree selection changed |
| UI state update check |
def f(items=[])Nonelambda: xlambda x=x: xTYPE_CHECKINGfield()field()@dataclassis==is==isNoneTrueFalse"".join()io.StringIOwx.CallAfter()wx.PostEvent()event.Skip()event.Skip()EVT_CLOSE_mgr.UnInit()with MyDialog(...) as dlg:SetPosition()SetSize()from platformdirs import user_config_dir, user_data_dir, user_cache_dir
config = user_config_dir("MyApp", "MyCompany") # %APPDATA% / ~/Library/... / ~/.config/
data = user_data_dir("MyApp", "MyCompany")
cache = user_cache_dir("MyApp", "MyCompany")# Run all tests
pytest
# Run specific test file
pytest tests/test_queue.py
# Run specific test
pytest tests/test_queue.py::test_submit_job -v
# With coverage
pytest --cov=mypackage --cov-report=term-missing
# Stop on first failure
pytest -x
# Show locals on failure
pytest -limport logging
def setup_logging(level: int = logging.INFO) -> None:
logging.basicConfig(
level=level,
format="%(asctime)s %(name)s %(levelname)s %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
# Quiet noisy libraries
logging.getLogger("httpx").setLevel(logging.WARNING)
logging.getLogger("httpcore").setLevel(logging.WARNING)| Platform | API | Python Binding |
|---|---|---|
| Windows | UI Automation | |
| Windows | MSAA/IAccessible2 | |
| macOS | NSAccessibility | |
# Set accessible name (screen reader label)
control.SetLabel("Descriptive Label")
# Set accessible description (supplementary info)
# Use wx.AccessibleDescription or wx.Accessible subclass
# Keyboard navigation
control.SetFocus() # Move focus programmatically
panel.SetFocusIgnoringChildren() # Focus the panel itself