Skip to content

Commit

Permalink
add pyshiny example
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhsmit committed Dec 2, 2024
1 parent 8560d69 commit 5079e82
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions examples/pyshiny_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from ipymolstar import PDBeMolstar
from shiny import reactive
from shiny.express import input, render, ui
from shinywidgets import reactive_read, render_widget

ui.input_text("molecule_id", "Molecule id", "1qyn")


@render_widget
def molstar():
view = PDBeMolstar(molecule_id="1qyn")
return view


@reactive.effect
def _():
molecule_id = input.molecule_id()
# check for valid pdb id
if len(molecule_id) == 4:
molstar.widget.molecule_id = input.molecule_id()


@render.text
def center():
event = reactive_read(molstar.widget, "mouseover_event")
return f"Mouseover event: {event}"

0 comments on commit 5079e82

Please sign in to comment.