You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromprolif.plotting.networkimportLigNetworkfromuuidimportuuid4fromhtmlimportescapefromIPython.displayimportHTML, JavascriptclassBetterLigNetwork(LigNetwork):
defdisplay(self, **kwargs):
"""Prepare and display the network"""html=self._get_html(**kwargs)
self.uuid=uuid4().hexiframe= (
'<iframe id="{uuid}" width="{width}" height="{height}" frameborder="0" ''srcdoc="{doc}"></iframe>'
)
returnHTML(
iframe.format(width=self.width, height=self.height, doc=escape(html), uuid=self.uuid)
)
defsave_png(self):
code=""" var iframe = document.getElementById("%(uuid)s"); var iframe_doc = iframe.contentWindow.document; var canvas = iframe_doc.getElementsByTagName("canvas")[0]; var link = document.createElement("a"); link.href = canvas.toDataURL(); link.download = "prolif-lignetwork.png" link.click(); """% {"uuid": self.uuid}
returnJavascript(code)
net=BetterLigNetwork.from_fingerprint(fp, ligand_mol)
net.display()
and when you're done drag-n-dropping things around, you'd simply run net.save_png(). You won't get the legend in the export though but that's less problematic.
Probably worth adding to the codebase at some point!
I'd really like the ipython notebook widget saved to png/svg. This is probably a pain, has it been looked into previously?
The text was updated successfully, but these errors were encountered: