Help creating comm between javascript and python using Voila

Hi all, this is my first post, sorry if this was discussed before (I couldn’t find it using the search bar).

We found a helpful solution for implementing voila dashboards for our scientists. It’s based on The Littlest Jupyter Hub + ContainDS dashboards, meaning that the more scripting-savvy users are able to export their notebooks as voilà applets, and the end-users (scientists less familiar with python/jupyter) can run some analysis without having to code or installing python on their computers.

The problem is with a specific javascript app we’re trying to bring to voila. So far, we manage to display the app both in jupyter notebook and while rendering using voila. However, the app is a GUI that is supposed to return a value when users click on the interface. In jupyter notebook, we manage to recover that value with another piece of javascript, which uses Jupyter.notebook.kernel.execute to write the value as a python variable. The variable can then be accessed inside the notebook and calculations can continue. However, when we launch this as a voila applet, the Jupyter.notebook.kernel method is not accepted anymore.

My question is: What is the proper way of achieving this? We tried using comm, but we end up having the same problems when we try to open comm from javascript using voila.

Any help would be greatly appreciated. I can try to provide some pieces of code, but our problems are very specific, I thought that it would be easier to just describe the issue.

Thanks in advance!

Sounds like you want to write a custom widget: Building a Custom Widget - Email widget — Jupyter Widgets 7.7.2 documentation

You might also want to check anywidget, since it simplifies the process a lot: GitHub - manzt/anywidget: custom jupyter widgets made easy