This example shows how to process a button event


Loading page, please wait ...



from js import document from pyodide import create_proxy count = 0 def button_click(event): global count count += 1 document.getElementById("msg").innerHTML = 'Button Clicked ' + str(count) def setup(): # The page is ready, clear the "page loading" document.getElementById("msg").innerHTML = '' # Create a JsProxy for the callback function click_proxy = create_proxy(button_click) # Set the listener to the callback e = document.getElementById("button") e.addEventListener("click", click_proxy) setup()