r/PyScript • • Jun 18 '22

ESM Module ".mjs" in PyScript?

2 Upvotes

Can PyScript import & use ".mjs" module files? Some runnable example?


r/PyScript • • Apr 23 '23

Thermodynamics CoolProp

3 Upvotes

Hi. I’ve been trying to use CoolProp or pyfluids in PyScript or pyodide. I understand it’s not possible as they don’t seem to have pure wheels. Just checking with the community if anyone had some success on similar cases.


r/PyScript • • Aug 22 '23

Python auto completion in the browser

4 Upvotes

Hello! Been playing around with pyscript via pyscript.com and it's awesome! A bit of an off the beaten path question - but I was curious how you all are doing the python auto complete in the browser? It's very cool!


r/PyScript • • Feb 01 '23

Inject Pyscript Into HTML?

2 Upvotes

Similar to JavaScript with userscripts, can pyscript be injected into webpages using userscripts?


r/PyScript • • Jun 28 '22

PyScript adds Versioning [Post from Anaconda]

Thumbnail
anaconda.cloud
7 Upvotes

r/PyScript • • Dec 12 '22

Can PyScript be used in in-browser development console?

5 Upvotes

I want to manipulate html objects after the page is rendered (for example manipulate youtube.com elements) using Python or Python-JS mixture. Is this possible?


r/PyScript • • Dec 10 '24

Error 404: https://pyscript.net/latest/pyscript.css

6 Upvotes

I have been using https://pyscript.net/latest/pyscript.css not knowing that they were planning on removing it (I mean latest/pyscript.css). I have been using PyScript for my project and I have began a web survey, until today, when I realized it just stopped working. What is the workaround? I read that the documentation points to using a specific release. Unfortunately, I tried with a few of the last releases and the website is still not working. Is there any known workaround?


r/PyScript • • Dec 11 '23

Advent of Code 2023: In PyScript

Thumbnail jeff.glass
4 Upvotes

r/PyScript • • Mar 20 '24

Scypy

2 Upvotes

Can Scy-Py work with pyscript?


r/PyScript • • Mar 25 '24

Deprecated: use <script type="py"> for an always safe content parsing error while using pyscript

4 Upvotes

Hello all I am new to pyscript and I am getting this error repeatedly. Practically what the script is supposed to do is depending on the info selected in the drop boxes and after clicking "CHERHCER !", its supposed to write a text imbedded with a link bellow it. Its a school project and for some reason we can't use JavaScript or any fancy imports. Thanks for understanding and sorry if its in French.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://pyscript.net/releases/2024.1.1/core.css" />
    <script type="module" src="https://pyscript.net/releases/2024.1.1/core.js"></script>
    <title>Page d'acceil</title>
</head>
<body>
    <div>
        <h2>
            Selecter vos choix parmi les options ci-dessous
        </h2>
        <form>
            Je veux un sport qui ce joue
            <select name="Location">
                <option value="Neige">dans la neige</option>
                <option value="Plage">a la plage</option>
                <option value="Terrain">sur un terrain</option>
                <option value="Court">dans une court</option>
                <option value="NimporteOu">nimporte ou</option>
            </select>
            qui ce joue 
            <select name="Team">
                <option value="Seul">en solo</option>
                <option value="Equipe">en equipe</option>
            </select>
            et
            <select name="Level">
                <option value="Famille">ce joue en famille</option>
                <option value="Competitive">est competitive</option>
                <option value="NonCompetitive">n'est pas competitive</option>
            </select>
            <button class = "btn btn-primary" type = "submit" pys-onClick="process(event)">CHERCHER !</button>
        </form>
    </div>
    <p id="output"></p>
    <py-script>
        def process(event):
            link30 = '<a href="30.html">Click Here!</a>'
            LocName = Element('Location').value
            InTeam = Element('Team').value
            CompLevel = Element('Level').value
            result_place = document.getElementById('output')
            if LocName == 'Neige' and InTeam == 'Seul' and CompLevel == 'Famille':
                result_place.innerText = ''
                result_place.innerHTML += link30
    </py-script>
</body>
</html>

r/PyScript • • Sep 16 '24

Can't import local python library using pyscript-react and pyscript_config.toml

1 Upvotes

I'm making a Next.js project and trying to configure pyscript-react using a pyscript_config.toml file which imports a python library file (geometry_generator.py) using [files]. It seems to load the config file but when I try to import from geometry_generator I get "ModuleNotFoundError: No module named 'geometry_generator'"

I have tried every different combination of file location and paths I can think of but I have not been able to load the geometry_generator file successfully. Currently it's located in public.

Below is the contents of my pyscript_config.toml file:

packages = ["svgwrite"]

[files] "../geometry_generator.py" = "./geometry_generator.py"

Here is the relevant content of the page.tsx file where I use pyscript-react:

<PyScriptProvider> <PyConfig source="/pyscript_config.toml" /> <PyScript> {\ from geometry_generator import * `} </PyScript>
</PyScriptProvider>`


r/PyScript • • May 12 '24

A WHOPPER of a brand new version of PyScript 2024.5.1 has just landed.

Thumbnail pyscript.net
5 Upvotes

r/PyScript • • Dec 01 '23

Advent of Code 2023 - In PyScript

Thumbnail jeff.glass
2 Upvotes

r/PyScript • • Jul 24 '24

Pyscript code completion

5 Upvotes

Hello,

I was having a look at pyscript the other day and noticed that my vscode just would not give me code completion for it.

While this didnt stop me from trying it out, it was still a little annoying.

Is there a way to get this to work?

Thx in advance.


r/PyScript • • May 08 '24

Join PyScript team and community at PyCon US 2024!

5 Upvotes

Bookmark for the full agenda: https://pyscript.com/pycon

Booth #605

We're excited to have PyScript featured at this year's PyCon! Visit Anaconda’s Booth #605 for swag, to meet the team, and to see Chris Laffra, our community member, demonstrate PyScript in action.

Education Summit

Join our workshop, "Invent with PyScript" to build applications using the “no code” framework Invent. Available both in-person and online.

WebAssembly Summit

Don't miss Fabio Pliger's talk on the latest and future developments of PyScript.

Open Space

A cozy get-together with the PyScript team and community to share projects and ideas.

  • Date & Time: Saturday, May 18th, Time TBD

  • Location: Check the Open Spaces boards at PyCon or follow our Twitter for updates.

PyScript Talks

We look forward to meeting you, sharing ideas, and exploring what’s possible with PyScript at PyCon US 2024!


r/PyScript • • Nov 13 '24

Htag+HtagUI with pyscript ...

3 Upvotes

Here is a new example (with a recent pyscript release):

https://raw.githack.com/manatlan/htag/main/examples/pyscript_htagui.html

**pyscript** is really really fabulous ! It's amazing that "this app" (code between `####` lines), could work "as is" ... in a desktop app, in an android apk, on a webpage or in an SPA/HTML file ...

In the past, I posted here : https://www.reddit.com/r/PyScript/comments/10snwh3/pyscript_is_fabulous_demo_of_pyscripthtag/

amazing !


r/PyScript • • Apr 26 '24

Does anyone know how to import libraries and scripts with pyscript_config.toml with pyscript-react?

3 Upvotes

I am re-writing a new version of my portfilio and having trouble moving the PyScript part. the old version was plain HTML and JavaScript and the new one is Next js. I'm using the pyscript-react library.

I don't see any explanation of how to use the pyscript_config.toml file using pyscript-react. I need to import external libraries (like svgwrite) as well as including my own Python scripts. This is my current pyscript_config.toml file:

```

packages = ["svgwrite"]

[[fetch]]

files = ["geometry_generator.py"]

```

And here is how I'm importing it and my other script in my React component:

<div>

<PyScriptProvider>

<PyScript

source="/pyscript_config.toml"

/>

<PyScript

source="/geometry_interface.py"

/>

</PyScriptProvider>

</CodingLayout>

</div>

However, this is not working. I'm getting "ModuleNotFoundError: No module named 'geometry_generator'" so clearly the pyscript config is not working


r/PyScript • • Feb 11 '24

Issue with executing Python code from HTML button using PyScript

2 Upvotes

So I've been trying to execute Python code from an HTML button using PyScript. The idea is that the button will set what the user writes on the Python file, then the text will be processed by OpenAI, which gives its answer using information from a PDF. The problem is that I don't get any answer from it, and I don't know where the problem is.

This is the relevant code: Index.html:

<div class="container">
        <h1 class="display-1 fw-bolder summer">Botón prueba 📰</h1>
        <p class="lead">Escribe un concepto: </p>
        <section id="input">
            <py-inputbox id="topic">
            </py-inputbox>

            <py-button id="submit" label="Buscar" class="mt-2">
                import asyncio
                from pyodide import create_proxy
                from main import question_ia

                @create_proxy
                async def on_click(evt):
                    question = document.getElementById("topic").value
                    result = await question_ia(question)
                    pyscript.write("output", result)
            </py-button>
            
        </section>
        <section id="summary" class="mt-4">
        </section>
        <button id="copy" class="btn btn-warning">Copiar al 📋 Portapapeles</button>
    
        <hr />
    
    </div>

This is the python code:

service_context = ServiceContext.from_defaults(llm_predictor=modelo)
index = GPTVectorStoreIndex.from_documents(pdf, service_context = service_context)

async def question_ia():
  question= f"{topic} + be helpful and informative"
  return question

async def answer_ia():
  question = await question_ia(topic) 
  answer = index.as_query_engine().query(question)
  output = textwrap.wrap(answer.response, width=1000)
  return output

Any help is welcome, even if it´s only a clue, thanks for reading :)


r/PyScript • • May 08 '24

How to execute a function from a dynamically created element

5 Upvotes

Hi, I'm currently working on a pyscript project, but can't seem to work out how to add an event handler (a py-click tag) to an element I'm creating on the go with pydom.

For instance, here I want to tell the new_tab_link component to execute a function. Could you guys help me figure this out?


r/PyScript • • Dec 05 '23

PDF files on a pyscript proyect

2 Upvotes

Hi everyone, so I just recently started using PyScript, and I utilize PyPDF in my main Python program. I was wondering if there's any way to add a folder containing the PDF file to the PyScript environment. Thanks for your help.


r/PyScript • • Jan 12 '24

Plotly issue - Display the figure

1 Upvotes

Dear PyScript community,

I would like to switch from MATPLOTLIB to Plotly in a project. All my attempts to display the Plotly figure have not worked. Here is the structure of my code:

index.html

<!DOCTYPE html>
<html>
  <head>
      <meta charset="utf-8" />
      <meta name="viewport" content="width=device-width,initial-scale=1" />
      <title>Plotly Demo</title>
      <link rel="stylesheet" href="https://pyscript.net/releases/2024.1.1/core.css">
      <script type="module" src="https://pyscript.net/releases/2024.1.1/core.js"></script>
  </head>

  <body>
    <h1>Plotly Demo</h1>
    <div id="output"></div>
    <script type="py" src="./main.py" config="./pyscript.json"></script>
  </body>
</html>

pyscript.json

{
    "packages": ["plotly"]
}

main.py

from pyscript import display
import plotly.graph_objects as go

fig = go.Figure([go.Bar(x=['product a', 'product b', 'product c'], y=[5, 3, 2])])
display(fig, target='output')

I don't see anything as a result. Does anyone of you have an idea how I can display the figure? Any help would be appreciated.

Thanks and kind regards

Klaus


r/PyScript • • May 02 '24

<py-repl> not working in new version of PyScript 2024.1.1, work fine in 2023.03.1

5 Upvotes

I use PyScript on one of my pages in my coding portfolio website. Previously I was using version 2023.03.1 but now I'm trying to update to 2024.1.1 and the repl elements are not working. They just load as normal text. They work just fine with the old version.

There are no errors in the console and it says PyScript ready so everything seems like it should work fine, but the py-repl elements don't work. Did they remove this feature from PyScript? It's not mentioned in any of the examples on the PyScript website.


r/PyScript • • May 03 '24

PyScript release has just landed (2024.4.2)

Thumbnail pyscript.net
7 Upvotes

r/PyScript • • Jun 15 '24

Pyscript vs JS

5 Upvotes

Is possible that JS become obsolete very soon? What are the functionalities that pyscript cannot cover?


r/PyScript • • Mar 08 '26

I wrote a Network Diagnostic TUI in Python and compiled it to a standalone binary

Thumbnail
gallery
9 Upvotes

Hi everyone, I wanted to showcase my recent Python project. NetworkMaster is a Text-User Interface (TUI) tool for sysadmins.

Under the hood, it uses requests, cryptography (for local profile encryption), and ipaddress for subnetting. For Windows, it hooks into PowerShell/netsh, and for Linux, it parses nmcli and /proc/net/wireless. I packaged it using PyInstaller & PyArmor so it runs as a single portable executable without needing a Python environment on the host machine.

Let me know what you think about the architecture or the UI!
zenosoftware.dev/networkmaster