Insert an SVG depiction of Mol into Image widget #3848
Replies: 2 comments 5 replies
-
I don't believe Jupyter has anyway to translate SVG into PNG (or JPG, or any of the formats that Is there any particular reason you don't just get the molecule image as an Image directly using |
Beta Was this translation helpful? Give feedback.
-
After some trial and error, I came up with a workaround: from rdkit.Chem import Draw
file_image = "my_molecule.svg"
Draw.MolToFile(mol, file_image)
image = widgets.Image.from_file(file_image) Basically, I write an SVG file with It would still be interesting to create an |
Beta Was this translation helpful? Give feedback.
-
I wish to insert the SVG depiction of a
Mol
object into an ipywidgetsImage
widget.I tried the following:
The resulting
image
is not displayed correctly.Everything would work perfectly if I inserted a PNG into the
Image
widget:The
Mol
object alone is displayed correctly as an SVG by Jupyter Lab (afterIPythonConsole.ipython_useSVG = True
). But I need the SVG to be in anImage
widget, since I am trying to make a composite widget object.Any suggestions are highly appreciated!
Configuration report
Beta Was this translation helpful? Give feedback.
All reactions