PyScript 🐍📜

Question:

You want to share this Python app with Grandma.


 print("Hello, world!")
          

How?

😬😲🤔😱

PyScript is...

...A platform for Python

in the browser.

PyBunny 🐰

https://tinyurl.com/h66e32nk


arrr.py

Polyglot 🏴‍☠️ 🦜☠️

https://ntoll.pyscriptapps.com/piratical/latest/

Runtimes

  • Pyodide
  • MicroPython
  • Lua
  • Ruby
  • ???

import js  # globalThis
          

from pyscript import window
          

from pyscript import document 
          
<button id="click-me">Click me! 🐭</button>
          
from js import document


def handler(e):
    """
    It's just Python! Access the DOM!
    """
    output = document.createElement("span")
    output.innerHTML = "🖱️"
    document.body.appendChild(output)


button = document.querySelector("button#click-me")
button.addEventListener("click", handler)

Clicky Mouse-o-Matic 🐁

https://tinyurl.com/yc4hjz33

Lights 💡 Cameras 🎥 Action 😄

https://tinyurl.com/4dtpmrcw

from pyscript import document
import time


counter = document.getElementById("counter")
i = 1


while True:
    counter.innerHTML = str(i)
    time.sleep(1)
    i += 1
<script type="mpy" src="./main.py" worker></script>

https://ntoll.pyscriptapps.com/worker-mcworkface/

Final thoughts

  • PyScript is a platform.
  • It runs everywhere a browser runs.
  • Anything a browser can do, so can PyScript.
  • Write code and frameworks on PyScript.
  • It's open source... come play!
  • For the 99% (not just coders).

What's next?

Questions..?

TL;DR:

pyscript.com - try 🐍

docs.pyscript.net - docs 📖

discord.gg/HxvBtukrg2 - chat 💬

Image credits

Photo by Dulcey Lima on Unsplash

Photo by Becca Tapert on Unsplash

Photo by Christian Wiediger on Unsplash

Photo by Valery Sysoev on Unsplash

Photo by Mathew Schwartz on Unsplash

Photo by Lia Trevarthen on Unsplash

Photo by Eric Wang on Unsplash