-
Notifications
You must be signed in to change notification settings - Fork 190
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
Allow support for saving png figure in py3Dmol #380
Comments
Calling pngURI directly on the viewer object should work, yes? |
I think so, if you can get hold of the viewer object? I spent a chunk of time trying to see if I could pull things from the cell output but got nowhere. I could capture cell output, buut that just returns javascript that references various js objects. The above recipe (which requires a fork or an update) was only way I could think of getting the data URI? If you have any other insights into what I could call from an .ipynb code cell to get a representation of the image, that would be really useful... |
Right, I wasn't thinking it through. There is no communication from JavaScript back to python. You'd have to use the jupyter comms mechanism to do that, which py3Dmol very explicitly avoids (should never need a running kernel for py3Dmol notebooks to work). I don't see how your provided recipe could work as it seems to mix python and javascript incompatibly. Does it work? |
Doh - and I'd misread - the Would it be possible to just run the js to get the data URI, return the data rather than the img html, and capture the returned data? (Or is there perhaps an easier way to run the js and get the response back directory into a python variable?) Below doesn't work, does it, because all we capture is the HTML? How do Maybe:
and then in the notebook, after displaying the viewer, in a new cell make the call and capture the output:
and then in another cell use the captured data:
|
I'm pretty sure %capture is only for python code. If you want to get values from javascript into python, you need to use the comms mechanism: |
See related issue on a generic widget2png idea: jupyter-widgets/ipywidgets#2280 |
I have a py3Dmol viewer object in my notebook. Forgive me for not following the above discussion... but can someone tell me how to go from py3DmolViewer object ---> png File explicitly? Everything I've tried and guessed at has not worked |
What happens when you call png on the view object? This works for me. |
That produces an image within my jupyter lab notebook. But no file (that I
can tell)
*Dr. Scott W Sides*
(303) 718-7028
…On Thu, Jan 2, 2020 at 1:19 PM David Koes ***@***.***> wrote:
What happens when you call png on the view object? This works for me.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#380?email_source=notifications&email_token=ADHTEK52CRIJF6CFVLPTNGTQ3ZD5JA5CNFSM4FPKZU32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEH7JAOI#issuecomment-570331193>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADHTEK3ZN275CQWFRVVOOOTQ3ZD5JANCNFSM4FPKZU3Q>
.
|
You can right click on the image to download it. If your goal is to automate the generation of images within python, this isn't the right tool. I recommend pymol. |
Thanks for the info. So pymol is still a wrapper around 3Dmol.js? The interface is more-or-less the same as py3Dmol? |
No, PyMOL is the open source software originally developed by Warren L. DeLano that is currently owned and supported by Schroedinger. You should be able to install the open source version using your favorite package manager. |
It would be useful if
https://github.com/3dmol/3Dmol.js/blob/master/py3Dmol/py3Dmol/__init__.py
was modified to allow the return of the image data URI as well as providing an image output for notebooks?Crudely, perhaps something like:
The text was updated successfully, but these errors were encountered: