posit-dev / py-shinywidgets

Render ipywidgets inside a PyShiny app
MIT License
41 stars 2 forks source link

suggestion - support for mols2grid, a chemistry viewing widget #55

Open iainmwallace opened 1 year ago

iainmwallace commented 1 year ago

mols2grid is a python widget to display molecule structures in a jupyter notebook.

It would be wonderful if this was supported in shiny to enable chemistry related app development

jhylin commented 1 year ago

In the last few days, I was trying to work on a PyShiny app that was similar to this one in Streamlit. I had 3 different versions of the app running in VS Code but they were all not quite what I intended. The idea was to utilise mols2grid package to view chemical structures in 2D formats, within the PyShiny app.

The closest version I've got was from using mols2grid.save() to generate a standalone html document: code - but this was not ideal as I'd like to show the 2D molecular structures inside the app, it was rather saving a copy of the html doc in my working directory.

The next closest version used mols2grid.to_pages() to try to generate the html document inside the app, but this produced the raw html code inside the app (rather than the usual html content shown on webpages) - code. I also tried to use shinyswidgets, but it didn't produce any output at all (however, I could see "MolGridWidget()" shown in the terminal every time I clicked on the input action button on the app) - code.

I thought to add my issue here, to follow on from the above suggestion to support mols2grid to see if this could be looked into, i.e. to add initialisation code, or perhaps my code were not right in the first place (I'm aware the action button might not be the best choice as an input, but I was purely testing to see if mols2grid would work with PyShiny by having these grids of 2D chemical structures showing up in the 1st place).

I'd appreciate any kind of help, as I've enjoyed building my first PyShiny app recently. In case this might be needed, here's the source code for mols2grid.