pyspage 
Quickly build open source web pages for academic purposes in a pythonic and elegant way.
Installation
pip install pyspage
An Example
Go to directory demo/, there is already a script scatter_hist.py.
pyspage scatter_hist.py -sb
A file named scatter_hist.html is generated, your browser opens a tab and show it.
Usage
Step 1
Create a new file named index.py which consists of mainly two parts, layout and script.
In the layout part, a layout variable should be defined, of which the contents are the page elements named in a way you like. The hierarchical relationships are expressed by indenting.
layout = '''
row_a
box
row_b
col_a
btn_a
col_b
btn_b
'''
In the script part, all the elements above should be created.
from pyspage import *
import matplotlib.pyplot as plt
row_a = Row()
row_b = Row()
col_a = Column()
col_b = Column()
box = Column(class_='col-6')
btn_a = Button('CLICK a')
btn_b = Button('CLICK b')
You can define a function and let an element run it on a certain event happens.
btn_a.onclick = lambda e: print('a is clicked!')
def click_b(e):
fig, ax = plt.subplots()
fruits = ['apple', 'blueberry', 'cherry', 'orange']
counts = [40, 100, 30, 55]
ax.bar(fruits, counts)
box.write(fig)
btn_b.onclick = click_b
def create_box():
row_a.classList.add('bg-warning')
box.write('This is the content.')
box.oncreate = create_box
You can create a figure with matplotlib or altair, and show it in an empty box(row or column) by box.write(fig).
Step 2
In your terminal, run as follow
pyspage index.py
a index.html in current directory is generated.
If you use the arguments -s(for server) and -b(for browser), pyspage will start a server on 127.0.0.1:8000 and open browser automatically.
pyspage index.py -sb
Deployment
This page can then be deployed on GitHub Pages, you don't have to bother about anything with HTML, JS or backend APIs.馃帀馃帀馃帀
Supported Elements (Todo List)
- Row
- Column
- Text
- Button
- Input
- Textarea
- SelectOne
- SelectMulti
- File
- Image
License
The MIT License.
Metadata
Release files for pyspage 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pyspage-0.0.3.tar.gz | 10.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyspage-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.3 kB
Release files / pyspage-0.0.3.tar.gz
| Download URL | pyspage-0.0.3.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd0d692f401f05ec6b82bfa9474c80a9807bd1d2128bf6c96faacc92966fed63
|
|
BLAKE2b-256 checksum How to use checksums |
398ff955785893e2951834d7b9b69d00322d4af5b6c8045fa334acc24202a419
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.7
|
Release files / pyspage-0.0.3-py3-none-any.whl
| Download URL | pyspage-0.0.3-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d9c213ae07ebcc065c8d52e07c937e879e6e0b8e9f6afeaa06f165a1b6c4fe03
|
|
BLAKE2b-256 checksum How to use checksums |
a51c24a1e5b0e4b1dfd5fce8fe7d377ab1f3533e7d0ca178e9afcb5e30f154c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.7
|
Security for pyspage 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.