cdfmlr / pyflowchart

Python codes to Flowcharts

Home Page:https://pypi.org/project/pyflowchart/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TODO Items

nightvision04 opened this issue · comments

It would be very handy indeed if there was a simple CLI for code->svg.

Flowchart.js is javascript (obviously), so how would you feel if I made a pull request that installed npm, and the npm 'diagrams' package? From there, it's really just a simple CLI interface once those 2 things are installed.

Thanks for your plan. Just feel free to begin your work with following things noticed:

  1. how to install the js environment in different platforms (Linux, macOS, Windows)
  2. npm & the needed package may be already installed. before install, detect it.

Hi - I have a Jupyter demo that wraps flowchart.js as a Jupyter widget (there may be better ways of packaging things...) and uses IPython magic to render code in magicked cells:

https://github.com/innovationOUtside/flowchart_js_jp_proxy_widget/

Issues: innovationOUtside/flowchart_js_jp_proxy_widget#2

image

Hi - I have a Jupyter demo that wraps flowchart.js as a Jupyter widget (there may be better ways of packaging things...) and uses IPython magic to render code in magicked cells:

https://github.com/innovationOUtside/flowchart_js_jp_proxy_widget/

Issues: innovationOUtside/flowchart_js_jp_proxy_widget#2

image

@psychemedia What a magic! A bit trouble to setup notwithstanding, it's useful.

Here is the detailed way to setup:

  1. install jp_proxy_widget
$ pip install jp_proxy_widget
$ jupyter nbextension install --py --symlink --sys-prefix jp_proxy_widget
$ jupyter nbextension enable --py --sys-prefix jp_proxy_widget
$ jupyter labextension install @jupyter-widgets/jupyterlab-manager
$ jupyter labextension install jp_proxy_widget
  1. install jp_flowchartjs
$ pip install jp_flowchartjs
  1. install pyflowchart
pip install pyflowchart
  1. Run jupyter lab, open a notebook, and run this:
from jp_flowchartjs.jp_flowchartjs import *
from IPython.core.magic import register_cell_magic
from pyflowchart import Flowchart

@register_cell_magic
def flowchart_magic(line, cell):
    "Send code to simulator."
    return FlowchartWidget().charter(cell, embed=True)
    
    
@register_cell_magic
def pyflowchart_magic(line, cell):
    "Generate flowchart code and send to flow charter."
    fc = Flowchart.from_code(cell)
    return FlowchartWidget().charter(str(fc.flowchart()), embed=True)
  1. then, enjoy the magic:
%%flowchart_magic
st=>start: Start
e=>end: End
op1=>operation: Generate
op2=>parallel: Evaluate
st(right)->op1(right)->op2
op2(path1, top)->op1
op2(path2, right)->e

&

%%pyflowchart_magic 
import time

def demo(msg='demo'):
    for i in range(10):
        print(f'{msg} loopcount is {i}')
        time.sleep(i)

I just simplified the setup; now you should just need to install the package and in a notebook run %load_ext jp_flowchartjs to make the magics available. Thanks for the prompt:-)