ipymolstar (anywidget) in solar app
I'm trying to put the ipymolstar PDBemolstar widget in a solara app.
(https://github.com/Jhsmit/ipymolstar; use master branch, release is broken)
this works:
and a new protien is loaded when you enter a PDB id
(also the viewer reloads when button is pressed but might be fixed with
use_memo
)
I've tried the .element API since I thought anywidgets count as ipywidgets?
c = PDBeMolstar.element(molecule_id=molecule_id.value)
but in this way there is no rerender when I change molecule_id
. Do i need to do anything else for that to work? the ipyleaflet example seem to work like this8 Replies
this should absolutely work, are you taking the most recent anywidget and solara?
in this example:
spin and hide water do update, which are callbacks on the js side.
link
Changing molecule_id requires a full rerender
GitHub
ipymolstar/src/ipymolstar/widget.js at ea81897743e5fb4790a552768177...
PDBeMolstar as anywidget. Contribute to Jhsmit/ipymolstar development by creating an account on GitHub.
what do you mean with "requires a fill rerender" ?
you want the widget to be re-created?
PDBeMolstar.element(
molecule_id=molecule_id.value, hide_water=hide_water.value, spin=spin.value
).key(f"mol-{molecule_id.value}") can achieve that
then it will re-create when the molecule_id changes, is that what you want?
Full re-render*
Oh that's what I said😄
Yeah I think I misunderstood how it works
I expected it would re-render but in retrospect that is not what I want
And I can use the key for now if I do
because i noticed you do not listen to molecule_id changes in the js
Yeah exactly
There is no direct helper method for that but I can make one I think with .update
what should the helper method do? would it work to do an @observe("molecule_id") and do the updating there?
On the js side there is an update method which I can use to draw the new molecule base on molecule id
Then I think the example will work and I won't need to redraw the whole thing