ui.py (2289B)
1 """Python-side API reference for Pytml 2.5. 2 3 The browser distribution provides this module dynamically through Pyodide. 4 """ 5 6 # The authoritative implementation is embedded by pytml.js so a CDN user does 7 # not need a separate Python package download. This file documents the module 8 # surface for source builds, editors and contributors. 9 10 class Event(dict): 11 """Event dictionary; the browser runtime also provides prevent_default().""" 12 def prevent_default(self): raise RuntimeError("Use the browser Pytml runtime") 13 def stop_propagation(self): raise RuntimeError("Use the browser Pytml runtime") 14 15 class Element: # pragma: no cover - browser implementation lives in pytml.js 16 def __init__(self, obj): self._obj = obj 17 18 class Joystick(Element): 19 pass 20 21 async def sleep(ms): raise RuntimeError("Use the browser Pytml runtime") 22 def element(target): raise RuntimeError("Use the browser Pytml runtime") 23 def get(target): return element(target) 24 def query(selector): return element(selector) 25 def query_all(selector): raise RuntimeError("Use the browser Pytml runtime") 26 def joystick(target): return element(target) 27 def timeout(callback, ms): raise RuntimeError("Use the browser Pytml runtime") 28 def interval(callback, ms): raise RuntimeError("Use the browser Pytml runtime") 29 def clear_timeout(timer_id): raise RuntimeError("Use the browser Pytml runtime") 30 def clear_interval(timer_id): raise RuntimeError("Use the browser Pytml runtime") 31 async def clipboard_copy(text): raise RuntimeError("Use the browser Pytml runtime") 32 async def clipboard_read(): raise RuntimeError("Use the browser Pytml runtime") 33 def alert(message): raise RuntimeError("Use the browser Pytml runtime") 34 def confirm(message): raise RuntimeError("Use the browser Pytml runtime") 35 def download(data, filename, mime='text/plain;charset=utf-8'): raise RuntimeError("Use the browser Pytml runtime") 36 def gamepads(): raise RuntimeError("Use the browser Pytml runtime") 37 def storage_get(key, fallback=None): raise RuntimeError("Use the browser Pytml runtime") 38 def storage_set(key, value): raise RuntimeError("Use the browser Pytml runtime") 39 def storage_remove(key): raise RuntimeError("Use the browser Pytml runtime") 40 def install(requirements, **kwargs): 41 import micropip 42 return micropip.install(requirements, **kwargs)