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

temporarily unavailable

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
row_b
    col_a
        btn_a
    col_b
        btn_b
'''

In the script part, all the elements above should be created.

from pyspage import *

row_a = Row()
row_b = Row()
col_a = Column()
col_b = Column()
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):
    print('b is clicked!')
btn_b.onclick = click_b

def create_row_a():
    row_a.classList.add('bg-warning')
    row_a.write('This is the content.')
row_a.oncreate = create_row_a

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.1.tar.gz (7.3 kB view hashes)

Uploaded Source

Built Distribution

pyspage-0.0.1-py3-none-any.whl (8.2 kB view hashes)

Uploaded Python 3

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