Why I am getting errors with the lastest version of PyScript?



    <title> Learn DOM for PyScript </title>

    <link rel='stylesheet' type='text/css' media='screen' href='https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css'>

    <link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />

    <script defer src="https://pyscript.net/latest/pyscript.js"></script>



<h1>Learn DOM Manipulation using PyScript</h1>

<h2>Simple String Counter using Python 🐍</h2>


<p>Input Text</p>

<textarea name="input_text" id="input_text" placeholder="Enter your text...."></textarea>


<button id="run" type="button" class="button is-primary" pys-onClick="count">Count</button>
<button id="clear" type="button" class="button is-danger" pys-onClick="clear">Clear</button>

<p>Output from 🐍</p>

<p id = 'output'></p>


input_text = Element("input_text")    

op = Element("output")

def clear(*args, **kwargs):

def count(*args, **kwargs):
    number = len(input_text.value)



Hi @Jorge , and welcome to the forum!

The preferred syntax for creating event handlers in PyScript is now to use py-[event] , where [event] is one of the many DOM Events. As in py-click=... or py-mouseover=... etc.

The “pys-on*” style has been deprecated and will be removed in a future version.

With the py-[event]syntax, the meaning of the attribute has changed slightly. Rather than passing a Callable, you give it actual python code to be evaluated. So in your case, you’d write py-click="count()" or py-click="clear().