neuralib.dashboard.base
Top View of bokeh application. |
|
A UI component that provides certain graph on specific data type. |
|
Bokeh application server. |
Bokeh Base module
- author:
Ta-Shun Su
[Bokeh](https://docs.bokeh.org/en/latest/) base module for building bokeh application which is web-based, interactive and python communicate-able.
Simple Example
>>> from neuralib.dashboard import BokehServer, View
>>> class Top(View):
... def setup(self):
... from bokeh.models import Div
... from bokeh.layouts import column
... return column(Div(text="Hello World!"))
>>> SERVER = BokehServer('Example')
>>> SERVER.start(Top())
General Application Structure
This structure proposol was following MVC common structure. For this module. M (Model) is defined as a group of functions that handle the data IO and processing. V (View) is defined as a group of classes that hold the bokeh UI components. C (Controller) is defined as a group of functions that bride the Model and View. They are UI event listeners, application controler and other kinds of function that nothing relate to the data.
>>> # data IO functions
... def list_data() -> list[str]: ...
>>> # Custom ViewComponent
... class DataView(ViewComponent): ...
>>> # Top View
... class Top(View):
... view_data: DataView
... def setup(self):
... # init view_data
... def update(self):
... # update view_data
... # controller functions
... def on_data_update(self, attr, old, value): ... # property change/update event
... def on_data_select(self, e): ... # action event
>>> # create cli parser (optional)
>>> # main function (optional)
>>> # create server