mypythontools.pyvueeel module — mypythontools 24-08-2021 documentation

# mypythontools.pyvueeel module

Common functions for Python / Vue / Eel project.

It contains functions for running eel, overriding eel.expose decorator, converting json to correct python format or transform data into form for vue tables and plots.

Go on

https://mypythontools.readthedocs.io/#project-starter

for example with working examples.

Image of such an app

mypythontools.pyvueeel.expose(callback_function)

  Wrap eel expose with try catch block and adding exception callback function (for printing error to frontend usually).

  Parameters

    callback_function (function) – Function that will be called if exposed function fails on some error.

mypythontools.pyvueeel.run_gui(devel=None, log_file_path=None, is_multiprocessing=False, builded_gui_path='default')

  Function that init and run eel project.

  It will autosetup chrome mode (if installed chrome or chromium, open separate window with no url bar, no bookmarks etc…) if chrome is not installed, it open microsoft Edge (by default on windows).

  In devel mode, app is connected on live vue server. Serve your web application with node, debug python app file that calls this function (do not run, just debug - server could stay running after close and occupy used port). Open browser on 8080.

  Debugger should correctly stop at breakpoints if frontend run some python function.

  Note

  Check project-starter on github for working examples and tutorial how to run.

  https://mypythontools.readthedocs.io/#project-starter

  Parameters

    - devel ((bool, None), optional) – If None, detected. Can be overwritten. Devel 0 run static assets, 1 run Vue server on localhost. Defaults to None.

    - log_file_path ((str, Path, None)), optional) – If not exist, it will create, if exist, it will append, if None, log to relative log.log and only if in production mode. Defaults to None.

    - is_multiprocessing (bool, optional) – If using multiprocessing in some library, set up to True. Defaults to False.

    - builded_gui_path ((str, Path, None)), optional) – Where the web asset is. Only if debug is 0 but not run with pyinstaller. If None, it’s automatically find (but is slower then). If ‘default’, path from project-starter is used - ‘gui/web_builded’ is used. Defaults to ‘default’.

  If you want to understand this technology more into detail, check this tutorial

  https://mypythontools.readthedocs.io/pyvueeel-tutorial.html

mypythontools.pyvueeel.to_table(df, index=False)

  Takes data (dataframe or numpy array) and transforms it to form, that vue-plotly library understands.

  Parameters

    - df (pd.DataFrame) – Data.

    - index (bool) – Whether use index as first column (or not at all).

  Returns

    DatPa in form for creating table in Vuetify v-data-table.

  Return type

    dict

mypythontools.pyvueeel.to_vue_plotly(data, names=None)

  Takes data (dataframe or numpy array) and transforms it to form, that vue-plotly understand.

  Links to vue-plotly:

  https://www.npmjs.com/package/vue-plotly https://www.npmjs.com/package/@rleys/vue-plotly - fork for vue 3 version

  Note

  In js, you still need to edit the function, it’s because no need to have all x axis for every column. Download the js function from project-starter and check for example.

  Parameters

    - data ((np.array, pd.DataFrame)) – Plotted data.

    - names (list, optional) – If using array, you can define names. Defaults to None.

  Returns

    Data in form for plotting in frontend.

  Return type

    dict