Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Bug]: MacOS screen capture causes wx backend exception #26587

Copy link
Copy link
Closed
@briantoby

Description

@briantoby
Issue body actions

Bug summary

When the screen capture shortcut (Shift+Control+Command+4) is used to record a MPL window, an exception occurs in backend_wx.py.

Code for reproduction

import matplotlib
matplotlib.use('WxAgg')
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
fruits = ['apple', 'blueberry', 'cherry', 'orange']
counts = [40, 100, 30, 55]
bar_labels = ['red', 'blue', '_red', 'orange']
bar_colors = ['tab:red', 'tab:blue', 'tab:red', 'tab:orange']
ax.bar(fruits, counts, label=bar_labels, color=bar_colors)
ax.set_ylabel('fruit supply')
ax.set_title('Fruit supply by kind and color')
ax.legend(title='Fruit color')
plt.show()

# run the above code (or anything else with WxAgg selected) in pythonw and
# then with the MPL window active, press Shift+Control at the same time

Actual outcome

This exception occurs:

Traceback (most recent call last):
  File "/Users/toby/mamba310/envs/py310all/lib/python3.10/site-packages/matplotlib/backends/backend_wx.py", line 753, in _on_key_down
    self._get_key(event), *self._mpl_coords(),
  File "/Users/toby/mamba310/envs/py310all/lib/python3.10/site-packages/matplotlib/backends/backend_wx.py", line 732, in _get_key
    if not (key_name == 'shift' and key.isupper()):
AttributeError: 'NoneType' object has no attribute 'isupper'

Expected outcome

no exception

Additional information

check if key is None before trying to use any methods of it

Operating system

MacOS 13.5

Matplotlib Version

3.6.2

Matplotlib Backend

WxAgg

Python version

3.10.8

Jupyter version

No response

Installation

conda

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.