Skip to content

Commit

Permalink
Callback for clicking on annotations lfoppiano/streamlit-pdf-viewer#76
Browse files Browse the repository at this point in the history
  • Loading branch information
t29mato committed Dec 3, 2024
1 parent a8108d0 commit 3dfdc1d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ def init_grobid():
init_grobid()


def my_custom_annotation_handler(annotation):
st.success(f"Annotation {annotation} clicked.")

def get_file_hash(fname):
hash_md5 = blake2b()
with open(fname, "rb") as f:
Expand Down Expand Up @@ -222,7 +225,8 @@ def get_file_hash(fname):
annotation_outline_size=annotation_thickness,
pages_to_render=st.session_state['page_selection'],
render_text=enable_text,
resolution_boost=resolution_boost
resolution_boost=resolution_boost,
on_annotation_click=my_custom_annotation_handler
)
else:
pdf_viewer(
Expand All @@ -233,5 +237,6 @@ def get_file_hash(fname):
annotation_outline_size=annotation_thickness,
pages_to_render=st.session_state['page_selection'],
render_text=enable_text,
resolution_boost=resolution_boost
resolution_boost=resolution_boost,
on_annotation_click=my_custom_annotation_handler
)

0 comments on commit 3dfdc1d

Please sign in to comment.