Build stand-alone App¶
PyInstaller bundles a Python application and all its dependencies into a folder or executable. The user can run the packaged app without installing a Python interpreter or any modules.
You can use PyInstaller to packages PyWebIO application into a stand-alone executable or folder:
Create a pyinstaller spec (specification) file:
pyi-makespec <options> app.py
You need replace
app.pyto your PyWebIO application file name.
Edit the spec file, change the
from pywebio.utils import pyinstaller_datas a = Analysis( ... datas=pyinstaller_datas(), ...
Build the application by passing the spec file to the pyinstaller command:
If you want to create a one-file bundled executable, you need pass
--onefile option in first step.
For more information, please visit: https://pyinstaller.readthedocs.io/en/stable/spec-files.html
PyWebIO supports for data visualization with the third-party libraries.
Bokeh is an interactive visualization library for modern web browsers. It provides elegant, concise construction of versatile graphics, and affords high-performance interactivity over large or streaming datasets.
You can use
bokeh.io.output_notebook(notebook_type='pywebio') in the PyWebIO session to setup Bokeh environment.
Then you can use
bokeh.io.show() to output a boken chart:
from bokeh.io import output_notebook from bokeh.io import show output_notebook(notebook_type='pywebio') fig = figure(...) ... show(fig)
See related demo on bokeh demo
In addition to creating ordinary charts, Bokeh can also build the Bokeh applications by starting the Bokeh server. The purpose of the Bokeh server is to make it easy for Python users to create interactive web applications that can connect front-end UI events to real, running Python code.
In PyWebIO, you can also use
bokeh.io.show() to display a Bokeh App. For the example, see bokeh_app.py.
Bokeh App currently is only available in the default Tornado backend
pyecharts is a python plotting library which uses Echarts as underlying implementation.
In PyWebIO, you can use the following code to output the pyecharts chart instance:
# `chart` is pyecharts chart instance pywebio.output.put_html(chart.render_notebook())
See related demo on pyecharts demo
plotly.py is an interactive, open-source, and browser-based graphing library for Python.
In PyWebIO, you can use the following code to output the plotly chart instance:
# `fig` is plotly chart instance html = fig.to_html(include_plotlyjs="require", full_html=False) pywebio.output.put_html(html)
See related demo on plotly demo
pyg2plot is a python plotting library which uses G2Plot as underlying implementation.
In PyWebIO, you can use the following code to output the pyg2plot chart instance:
# `chart` is pyg2plot chart instance pywebio.output.put_html(chart.render_notebook())
See related demo on plotly demo
cutecharts.py is a hand drawing style charts library for Python which uses chart.xkcd as underlying implementation.
In PyWebIO, you can use the following code to output the cutecharts.py chart instance:
# `chart` is cutecharts chart instance pywebio.output.put_html(chart.render_notebook())
See related demo on cutecharts demo