Skip to content

Capture scroll#322

Merged
jcapriot merged 1 commit intomainfrom
fix_scroll_capture
May 30, 2023
Merged

Capture scroll#322
jcapriot merged 1 commit intomainfrom
fix_scroll_capture

Conversation

@prisae
Copy link
Member

@prisae prisae commented May 29, 2023

The behaviour changed with the advent of ipympl (Lab; modern Notebook), I think. Currently the scroll over a figure makes the notebook keep scrolling, so it is hard to scroll over a slicer-image through the volume.

This PR implements the fix suggested by Matplotlib (PR 235).

This changed I we the advent of ipympl (Lab; modern Notebook). Now the scroll over a figure make the notebook keep scrolling, so it is hard to scroll over a slicer-image through the volume.

This PR implements the fix suggested by Matplotlib (PR 235).
@codecov
Copy link

codecov bot commented May 29, 2023

Codecov Report

Merging #322 (48deb4b) into main (0f9fe1f) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #322   +/-   ##
=======================================
  Coverage   85.41%   85.41%           
=======================================
  Files          38       38           
  Lines       11420    11421    +1     
=======================================
+ Hits         9754     9755    +1     
  Misses       1666     1666           
Impacted Files Coverage Δ
discretize/mixins/mpl_mod.py 72.55% <100.00%> (+0.02%) ⬆️

@jcapriot
Copy link
Member

Looks good to me, I'm assuming you've tested this yourself and it works well on your end too

@prisae
Copy link
Member Author

prisae commented May 30, 2023

"Have tested it" is probably a big word. It worked locally in a Python 3.11 environment, I checked with Jupyter Lab, and also that it doesn't break in IPython.

@prisae
Copy link
Member Author

prisae commented May 30, 2023

However, the fig.canvas attribute exists always, as in other parts of the code we set

fig.canvas.mpl_connect("scroll_event", tracker.onscroll)

to listen to the scroll events. So setting

self.fig.canvas.capture_scroll = True

Should always be possible, and I cannot imagine that it has any negative side effects. It was created for this reason.

Let me know if you would prefer that I do a more thorough testing.

@prisae
Copy link
Member Author

prisae commented May 30, 2023

As reference maybe also this:
https://matplotlib.org/ipympl/examples/full-example.html#comprehensive-example
(9th cell from the top)

@jcapriot jcapriot merged commit f0269eb into main May 30, 2023
@jcapriot jcapriot deleted the fix_scroll_capture branch May 30, 2023 23:01
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.

2 participants