How to trigger custom event on a hamburger menu option click


For my use case I want to run small ajustements on the app content before printing it with the print option button in the hamburger menu.


import streamlit as st
st.write("<p id='PrintSpaceBlock'>test</p>", unsafe_allow_html=True)

Manually changing the content in the console:

element = document.getElementById("PrintSpaceBlock")
backup = element.innerHTML
element.innerHTML = "test<br><br>test"

Printing the app:

Restoring the original content after the print:

element.innerHTML = backup


How to make the print button automatically triggers the javascript code for pre and post processing as shown above ?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.