mirror of
https://github.com/pyscript/pyscript.git
synced 2026-02-27 11:04:05 -05:00
Merge branch 'main' into quickfix/pyscript_loading_sequence
This commit is contained in:
@@ -114,8 +114,17 @@ pyscript.write('pi', f'π is approximately {pi:.3f}')
|
||||
|
||||
In addition to the [Python Standard Library](https://docs.python.org/3/library/) and
|
||||
the `pyscript` module, many 3rd-party OSS packages will work out-of-the-box with PyScript.
|
||||
In order to use them you will need to declare the dependencies using the `<py-env>` in the
|
||||
HTML head.
|
||||
|
||||
In order to use them you will need to delcare the dependencies using the `<py-env>` in the
|
||||
HTML head. You can also link to `.whl` files directly on disk like in our [toga example](https://github.com/pyscript/pyscript/blob/main/pyscriptjs/examples/toga/freedom.html)
|
||||
|
||||
```
|
||||
<py-env>
|
||||
- './static/wheels/travertino-0.1.3-py3-none-any.whl'
|
||||
</py-env>
|
||||
```
|
||||
|
||||
If your `.whl` is not a pure Python wheel then open a PR or issue with [pyodide](https://github.com/pyodide/pyodide) to get it added here https://github.com/pyodide/pyodide/tree/main/packages. If there's enough popular demand the pyodide team will likely work on supporting your package, regardless things will likely move faster if you make the PR and consult with the team to get unblocked.
|
||||
|
||||
For example, NumPy and Matplotlib are available. Notice here we're using `<py-script output="plot">`
|
||||
as a shortcut, which takes the expression on the last line of the script and runs `pyscript.write('plot', fig)`.
|
||||
@@ -197,4 +206,5 @@ fig
|
||||
</py-script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
10
README.md
10
README.md
@@ -5,14 +5,16 @@
|
||||
### tl;dr
|
||||
PyScript is a Pythonic alternative to Scratch, JSFiddle or other "easy to use" programming frameworks, making the web a friendly, hackable, place where anyone can author interesting and interactive applications.
|
||||
|
||||
To demonstrate pyscript, see [the pyscript folder](pyscriptjs/README.md).
|
||||
To get started see [GETTING-STARTED](GETTING-STARTED.md).
|
||||
|
||||
For examples see [the pyscript folder](pyscriptjs/README.md).
|
||||
|
||||
### Longer Version
|
||||
PyScript is a meta project that aims to combine multiple open technologies to create a framework for users to use Python (and other languages) to create sophisticated applications in the browser. It highly integrates with the way the DOM works in the browser and allows users to add logic, in Python, in a way that feels natural to web as well as Python developers.
|
||||
|
||||
## Try PyScript
|
||||
|
||||
To try PyScript, import the pyscript to your html page with:
|
||||
To try PyScript, import the appropriate pyscript files to your html page with:
|
||||
```
|
||||
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
|
||||
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
|
||||
@@ -28,9 +30,9 @@ Check out the `/examples` folder for more examples on how to use it, all you nee
|
||||
|
||||
To contribute:
|
||||
|
||||
* clone the repo
|
||||
* clone the repo `git clone https://github.com/pyscript/pyscript`
|
||||
* cd into the main project folder with `cd pyscriptjs`
|
||||
* install the dependencies with `npm install`
|
||||
* install the dependencies with `npm install` - make sure to use nodejs version >= 16
|
||||
* run `npm run dev` to build and run the dev server. This will also watch for changes and rebuild when a file is saved
|
||||
|
||||
## Resources
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</head>
|
||||
<py-env>
|
||||
- paths:
|
||||
- /antigravity.py
|
||||
- ./antigravity.py
|
||||
</py-env>
|
||||
<body>
|
||||
<b>Based on xkcd: antigravity https://xkcd.com/353/.</b>
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
<input id="y1" type="text" value="5.0" style="width: 80px; text-align: right">
|
||||
<span style="white-space: pre">]</span>
|
||||
</div>
|
||||
<div style="display: flex; flex-direaction: row; gap: 1em">
|
||||
<div style="display: flex; flex-direction: row; gap: 1em">
|
||||
<div style="white-space: pre"><input type="radio" id="conv" name="type" value="convergence" checked> convergence</div>
|
||||
<div style="white-space: pre"><input type="radio" id="iter" name="type" value="iterations"> iterations</div>
|
||||
</div>
|
||||
@@ -82,8 +82,8 @@
|
||||
- numpy
|
||||
- sympy
|
||||
- paths:
|
||||
- /palettes.py
|
||||
- /fractals.py
|
||||
- ./palettes.py
|
||||
- ./fractals.py
|
||||
</py-env>
|
||||
|
||||
<py-script>
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="default">
|
||||
<meta name="theme-color" content="#0072b5">
|
||||
<meta name="name" content="Pyscript/Panel DeckGL Demo">
|
||||
<meta name="name" content="PyScript/Panel DeckGL Demo">
|
||||
|
||||
<title>Pyscript/Panel DeckGL Demo</title>
|
||||
<title>PyScript/Panel DeckGL Demo</title>
|
||||
<link rel="icon" type="image/x-icon" href="./favicon.png">
|
||||
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" type="text/css" />
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
<py-env>
|
||||
- paths:
|
||||
- /antigravity.py
|
||||
- ./antigravity.py
|
||||
</py-env>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
- bokeh
|
||||
- numpy
|
||||
- paths:
|
||||
- /utils.py
|
||||
- /antigravity.py
|
||||
- ./utils.py
|
||||
- ./antigravity.py
|
||||
</py-env>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<script defer src="../build/pyscript.js"></script>
|
||||
<py-env>
|
||||
- paths:
|
||||
- /utils.py
|
||||
- ./utils.py
|
||||
</py-env>
|
||||
</head>
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<script defer src="/build/pyscript.js"></script>
|
||||
<py-env>
|
||||
- paths:
|
||||
- /utils.py
|
||||
- ./utils.py
|
||||
</py-env>
|
||||
</head>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as jsyaml from 'js-yaml';
|
||||
|
||||
import { pyodideLoaded, loadedEnvironments, mode, addInitializer } from '../stores';
|
||||
import { pyodideLoaded, addInitializer } from '../stores';
|
||||
import { loadPackage, loadFromFile } from '../interpreter';
|
||||
|
||||
// Premise used to connect to the first available pyodide interpreter
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BaseEvalElement } from './base';
|
||||
import { addClasses, ltrim, htmlDecode } from '../utils';
|
||||
import { addClasses, htmlDecode } from '../utils';
|
||||
|
||||
export class PyTitle extends BaseEvalElement {
|
||||
shadow: ShadowRoot;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from js import document, setInterval, console
|
||||
import micropip
|
||||
from js import document, console
|
||||
import asyncio
|
||||
import io, base64, sys
|
||||
import io, base64
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user