Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
briantoby opened this issue Aug 24, 2023 · 2 comments
Closed

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

briantoby opened this issue Aug 24, 2023 · 2 comments
Labels
status: needs clarification Issues that need more information to resolve.

Comments

@briantoby
Copy link

briantoby commented Aug 24, 2023

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

@ksunden
Copy link
Member

ksunden commented Aug 24, 2023

The code for wx modifier keys was basically whole cloth re-written in #23473, which was released as part of 3.7.0, and I think this is no longer possible, from my reading of the code (but I do not have a mac to test with).

Can you test with newer Matplotlib, please?

@QuLogic QuLogic added the status: needs clarification Issues that need more information to resolve. label Aug 24, 2023
@briantoby
Copy link
Author

Indeed, 3.7.2 fixes this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs clarification Issues that need more information to resolve.
Projects
None yet
Development

No branches or pull requests

3 participants