MCPcopy Index your code
hub / github.com/pyscript/pyscript / __setattr__

Method __setattr__

core/src/stdlib/pyscript/web.py:536–552  ·  view source on GitHub ↗

Set an attribute on the element. Private attributes (starting with `_`) are set on the Python object. Public attributes are set on the underlying DOM element. Attributes starting with `on_` are treated as events.

(self, name, value)

Source from the content-addressed store, hash-verified

534 return getattr(self._dom_element, dom_name)
535
536 def __setattr__(self, name, value):
537 """
538 Set an attribute on the element.
539
540 Private attributes (starting with `_`) are set on the Python object.
541 Public attributes are set on the underlying DOM element. Attributes
542 starting with `on_` are treated as events.
543 """
544 if name.startswith("_"):
545 super().__setattr__(name, value)
546 elif name.startswith("on_"):
547 # Separate events...
548 self.get_event(name).add_listener(value)
549 else:
550 # ...from regular attributes.
551 dom_name = self._normalize_attribute_name(name)
552 setattr(self._dom_element, dom_name, value)
553
554 def _normalize_attribute_name(self, name):
555 """

Callers

nothing calls this directly

Calls 3

get_eventMethod · 0.95
add_listenerMethod · 0.80

Tested by

no test coverage detected