mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-20 10:47:35 -05:00
* kill the PyScript class and the weird pyscript instance; from the user point of view its functionalities are still available as pyscript.*, but pyscript is not the module, not the instance of PyScript * simplify the code in _set_version_info, while I'm at it * start to implement DeprecatedGlobal * DeprecatedGlobal.__getattr__ * don't show the same warning twice * DeprecatedGlobal.__call__ * make it possible to specify a different warning message for every global * WIP: carefully use DeprecatedGlobal to show reasonable warning messages depending on which name you are accessing to. More names to follow * deprecate more names * deprecate private names * depreacte direct usage of console and document * deprecate the PyScript class * use a better error message * fix test_pyscript.py * introduce a __repr__ for DeprecatedGlobal * add an helper to ensure that we don't show any error or warning on the page * WIP: ensure that examples don't use depreacted features. Many tests are failing * don't deprecate Element * don't use the global micropip to install packages, else we trigger a warning * use a better error message for micropip * fix test_todo_pylist to avoid using deprecated globals * fix test_webgl_raycaster * fix tests * make HTML globally available * add MIME_RENDERERS and MIME_METHODS * fix the typing of Micropip, thanks to @FabioRosado
22 lines
549 B
Python
22 lines
549 B
Python
from datetime import datetime as dt
|
|
|
|
import pyscript
|
|
|
|
|
|
class PyItem(pyscript.PyItemTemplate):
|
|
def on_click(self, evt=None):
|
|
self.data["done"] = not self.data["done"]
|
|
self.strike(self.data["done"])
|
|
|
|
self.select("input").element.checked = self.data["done"]
|
|
|
|
|
|
class PyList(pyscript.PyListTemplate):
|
|
item_class = PyItem
|
|
|
|
def add(self, item):
|
|
if isinstance(item, str):
|
|
item = {"content": item, "done": False, "created_at": dt.now()}
|
|
|
|
super().add(item, labels=["content"], state_key="done")
|