Skip to main content

Quickly build open source web pages for academic purposes in a pythonic and elegant way.

Project description

pyspage

Quickly build open source web pages for academic purposes in a pythonic and elegant way.

Installation

pip install pyspage

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 directionary 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

This page can then be deployed on GitHub Pages, you don't have to bother about anything with HTML, JS or backend APIs.馃帀馃帀馃帀

License

The MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyspage-0.0.2.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

pyspage-0.0.2-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file pyspage-0.0.2.tar.gz.

File metadata

  • Download URL: pyspage-0.0.2.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for pyspage-0.0.2.tar.gz
Algorithm Hash digest
SHA256 57055108069503ed98c3988c711d2889f628523f2733ab587e161429fb81d0f7
MD5 07bdf2e8d195ad36ad935fb5c8994fc8
BLAKE2b-256 0bd0672b8066cce7aa0c2fe62267d170334f56fb683e726a6f2797c9328feba3

See more details on using hashes here.

File details

Details for the file pyspage-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pyspage-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for pyspage-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 066c856017efacd7a3bc52b1aee5ce25311a3502a54e350d57230ec54f68d11b
MD5 1980c3004d2d1f41f3b127d774f7b046
BLAKE2b-256 270f23128565abba197196d0d50ffa13e7f410b2e9bbaa101cc9d4c575333d16

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page