Guild icon
PyScript 💻
🗑 | Server Dump / ╰╸queries-you-faced
Avatar
Leonard Wolf 17/05/2022 07:09
⬇️ List down queries you faced while using PyScript so that other people if face it can solve it by reading your solution! ⬇️
Avatar
Jeff Glass 23/05/2022 15:32
Wanted to leave this here in case others find it useful - I helped a reddit user track down an obscure issue in a package they were trying to include: https://www.reddit.com/r/PyScript/comments/uux74y/comment/i9opv74/?utm_source=share&utm_medium=web2x&context=3
✅ 3
15:33
TL;DR: if you're seeing the error ModuleNotFoundError: No module named pkg_resources, include setuptools in your <pv-env> tag before the package you're trying to install. The package you're trying to use is assuming pkg_resources (part of the setuptools module) is always available, which isn't necessarily the case.
✅ 3
Avatar
Jeff Glass 27/05/2022 16:00
Downloading files containing content form on-page forms: https://discord.com/channels/972017612454232116/972020206538997822/979750984823754802
✅ 3
Avatar
How to use pys-onClick on dynamically added element? Note: setAttribute won't work. Solution: Things were bit tricky: Here is link incase someone needs this in future (It was issue opened by someone on PyScript repo, I just posted code there, sharing just link to keep chat clean) https://github.com/pyscript/pyscript/issues/461#issuecomment-1140294597
Describe the bug I have a page with a html button using the pys-onClick attribute to call a function which adds another div with a button. The second button has the pys-onClick attribute but does n...
✅ 14
Avatar
Jeff Glass 31/05/2022 16:10
What custom tags does PyScript make available? Not that this clarifies what each of them do, but from the source on GitHub, in the main.ts file, we can see that the current pyscript tags are: py-script py-repl py-env py-box py-button py-title py-inputbox py-register-widget py-loader and py-config. https://github.com/pyscript/pyscript/blob/698478ef95b396a5de4b9b330dbd9bd796d3861f/pyscriptjs/src/main.ts#L15-L24
Home Page: https://pyscript.net Examples: https://pyscript.net/examples - pyscript/main.ts at 698478ef95b396a5de4b9b330dbd9bd796d3861f · pyscript/pyscript
✅ 15
Avatar
By default pyodide will convert dictionaries to js maps. Sometimes you actually want it to be a js object. So do this from js import Object to_js(your_dictionary, dict_converter=Object.fromEntries) (edited)
✅ 15
Avatar
How to invoke python functions in javascript? 1. Get Pyodide (pyscript is based on this) <script src="https://cdn.jsdelivr.net/pyodide/v0.20.0/full/pyodide.js"></script> 2. Load pyodide and python packages you need
  • let pyodide = await loadPyodide();
  • pyodide.loadPackage("numpy");
3. Execute python code - pyodide.runPython(` import sys sys.version `) more - https://pyodide.org/en/stable/usage/quickstart.html#accessing-python-scope-from-javascript
✅ 22
Avatar
zaki 🇱🇰 18/08/2022 23:33
If you have an image with a base64 src, you can import it to pillow without much hassle: (adapted from jeffGlass' pillow import) from js import document, console import io import re import base64 from PIL import Image img2Bytes = document.getElementById("image").src image_b64 = re.sub('^data:image/.+;base64,', '', img2Bytes) # .decode('base64') image_data = base64.b64decode(image_b64) g_image = Image.open(io.BytesIO(image_data)) # Log some of the image data for testing console.log(f"{g_image.format= } {g_image.width= } {g_image.height= }") if anyone has any suggestions for optimising this code, please let me know. (edited)
👍 22
Avatar
Ajay Kumar 30/04/2023 10:40
Hi All, Is there anyone who can help to setup PyScript local dev env on window https://github.com/pyscript/pyscript/discussions/1426 <<-- discussion is already going on. Any input related to this will be much appreciated. Thanks
If someone can recognize the screenshot below please help me get the dev env setup. I wanted to contribute to the project. While running the make setup command, it getting failed. refer to the belo...
Avatar
ttetea642@gmail.com 20/11/2024 01:45
How to feedback back
Avatar
Original message was deleted or could not be loaded.
Does spam like this actually work? I doubt you'll find any success here.
Exported 12 message(s)
Timezone: UTC+0