Skip to content

feat: add a ? key to idisp that prints the list of keys - #215

Merged
petercorke merged 1 commit into
mainfrom
feat/idisp-key-help
Nov 22, 2026
Merged

petercorke merged 1 commit into
mainfrom
feat/idisp-key-help

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

Pressing ? in an idisp window now prints a concise list of the keys it responds to, in the terminal or, in a notebook, in the cell output:

idisp keys:
  ?  show this help
  q  close the window
  c  copy the pixel position u,v to the clipboard
  C  append the pixel position to the clipboard
  v  copy the pixel position and value
  V  append the pixel position and value
  x  clear the clipboard
Matplotlib: f full screen, g grid, h home, p pan, o zoom, s save

The clipboard keys are listed only when pyclip is installed. Without it, one line says c C v V x clipboard keys, need pyclip: pip install pyclip instead. The key works with the cursor anywhere in the figure, and is handled before the pyclip check, so it works without pyclip. h is deliberately not used, because Matplotlib binds it to "home" (reset the view). The idisp docstring lists the new key, with .. versionadded:: 2.5.0.

This PR is stacked on the fix to the v and V clipboard keys (branch bug/idisp-clipboard-scalars), because both edit the same key handler. Until that merges, the diff shown here includes its commits; after it merges, the diff is only this feature.

Testing

pytest tests/base/test_idisp_options.py: 43 passed; the new tests fail without the feature. They cover the help with and without pyclip, a keypress outside the image, other keys printing nothing, and a limit on the length of the text. mypy reports no issues. The clipboard is a stand-in for pyclip and I did not try the key in a live window. Not run: CI on Windows or OpenCV 4 (CI will).

This change was written with AI assistance (Claude Code) and the diff has been read by the maintainer.

🤖 Generated with Claude Code

Pressing ? in an idisp window prints a concise list of the keys it
responds to. The clipboard keys are listed only when pyclip is installed,
otherwise one line says they need it. h is not used, since Matplotlib
binds it to home. The idisp docstring lists the new key.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 19 complexity · 0 duplication

Metric Results
Complexity 19
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@petercorke
petercorke merged commit 3e5dcab into main Nov 22, 2026
32 checks passed
@petercorke
petercorke deleted the feat/idisp-key-help branch November 22, 2026 03:49
@github-actions github-actions Bot mentioned this pull request Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant