GLVis / pyglvis

GLVis Jupyter Widget
BSD 3-Clause "New" or "Revised" License
12 stars 3 forks source link

Screenshot support #25

Closed tomstitt closed 2 years ago

tomstitt commented 2 years ago

Note: this requires a yet-to-be released version of glvis from npm that I'm working with locally. We can update glvis once https://github.com/GLVis/glvis-js/pull/11 & https://github.com/GLVis/glvis/pull/195 are merged.

Right now the screenshot is triggered from JavaScript so the usual browser download rules apply. Here is what things look like:

TODO:

Screen Shot 2021-08-25 at 3 31 26 PM

And the actual output: star(4)

Another option would be to get the screen state back to Python and write the file from there. We wouldn't be "downloading" it in the same way.

I think I like the Python approach more because there wouldn't be a download dialog (then again Chrome just downloads the files without a dialog) but I need to try a few more things to get it working.

Is there anything else you were hoping for @rw-anderson, @tzanio , @kmittal2? (I saw you all participated in some way or another on https://github.com/GLVis/pyglvis/issues/5)

addresses: https://github.com/GLVis/pyglvis/issues/5

rw-anderson commented 2 years ago

"Another option would be to get the screen state back to Python and write the file from there. We wouldn't be "downloading" it in the same way."

This seems preferable for the use case that raised this issue in the first place for me. I wanted to create "galleries" of examples programmatically, maybe 20 at a time or something in that ballpark. If I had to navigate 20 download dialogs, that would be a big bottleneck.

But reading more carefully, if chrome just downloads without a dialog, that seems fine, too.

tomstitt commented 2 years ago

I added an option to download via Python with the caveat that since the messaging is asynchronous we don't (can't easily) block so there is either no feedback when you .screenshot or there is an output but it is under the widget not the cell you ran screenshot; a little weird for sure but I tested with ex9 and it saved all the images