Skip to content

[Bug]: key_press_event not working for TkAgg backend on Windows from Python 3.9.9 #22255

Closed
@ebardie

Description

@ebardie

Bug summary

On Windows, but not on Linux, with Python 3.9.8 installed, key_press_events both work for the two examples from the MPL documentation:

Keypress demo

Embedding TkInter demo

The "Keypress demo" will not work with a clean install of Python 3.9.9 (i.e one not upgraded from an earlier Python 3.9.x release. Deleting a previous install and obliterating the install directory is fine. Just upgrading, or uninstalling without obliteration, are not enough.

The problem exists in Python 3.10 on Windows.

The problem is not there for the Qt5Agg backend.

Code for reproduction

1. Perform a clean install of Python 3.9.9 on Windows.
2. Install matplotlib.
3. Copy the code from the
[Keypress demo](https://matplotlib.org/stable/gallery/event_handling/keypress_demo.html?highlight=key_press_event) in to a file.
4. Run it.
5. Press some keys.
5. Note stdout.

Actual outcome

Stdout will be empty.

Expected outcome

Stdout should say things like:

press a
press a
press a
press a
press a
press a
press b
press c
press d
press e

Additional information

No response

Operating system

Windows

Matplotlib Version

Any I've tested from 3.3.0 up to 3.5.1

Matplotlib Backend

TkAgg

Python version

3.9.9

Jupyter version

n/a

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions