Metadata-Version: 2.1
Name: sim2lbuilder
Version: 0.0.7
Summary: Simtool builder
Home-page: https://github.com/denphi/sim2lbuilder
Author: nanoHUB
Author-email: denphi@denphi.com
License: BSD
Keywords: IPython
Platform: Linux
Platform: Mac OS X
Platform: Windows
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Framework :: Jupyter
Description-Content-Type: text/markdown
Requires-Dist: ipywidgets (>=7.5.0)
Requires-Dist: simtool (>=0.3.3)
Requires-Dist: ipython (>=7.4.0)
Requires-Dist: traitlets (>=4.3.2)
Requires-Dist: ipysheet (>=0.4.1)
Requires-Dist: nanohub-uidl (>=0.1.5)
Requires-Dist: Pillow (>=7.2)
Provides-Extra: docs
Provides-Extra: examples
Provides-Extra: test

# Sim2lBuilder Stats

<table>
    <tr>
        <td>Latest Release</td>
        <td>
            <a href="https://pypi.org/project/sim2lbuilder/"/>
            <img src="https://badge.fury.io/py/sim2lbuilder.svg"/>
        </td>
    </tr>
    <tr>
        <td>PyPI Downloads</td>
        <td>
            <a href="https://pepy.tech/project/sim2lbuilder"/>
            <img src="https://pepy.tech/badge/sim2lbuilder/month"/>
            <img src="https://pepy.tech/badge/sim2lbuilder"/>
        </td>
    </tr>
</table>

# Simtool Builder


## Introduction

sim2lbuilder is an utility library to create Graphical User interfaces on Jupyter notebooks.
sim2lbuilder is based on ipywidgets, and allow users to describe Apps based on their inputs, outputs and layout. Callback functions can also be referenced to be triggered by events on the widgets
sim2lbuilder can display described tools as widgets, or generate python code to be modified.

## Installation


```bash
pip install sim2lbuilder
```


## Usage


```python
schema = {
  'inputs': { 
    'n1': { 'type': 'IntText', 'value': 1}, 
    'n2': { 'type': 'IntText', 'value': 3}
  },
  'outputs': { 
    'sol': { 'type': 'IntText'}, 
  },
  'layout': { 
    'type': 'HBox',
    'children' : {
      'n1': None,
      'n2': None,
      'button' : {
        'type': 'Button',
        'click': 'SUM',
        'description': '=',
      },
      'sol': None
    }
  }
}
from sim2lbuilder import WidgetConstructor
s = WidgetConstructor(schema)
def SUM (w):
    w.outputs["sol"].value = w.inputs["n1"].value + w.inputs["n2"].value
s.SUM = SUM
s.assemble()
SUM(s)
display(s)

```

## Create a Sim2l GUI (Widget) 


```python
from sim2lbuilder import WidgetConstructor, GetSimtoolDefaultSchema
from simtool import searchForSimTool, getSimToolInputs, Run
schema = GetSimtoolDefaultSchema("meltingkim")
def RunSimTool(widget, *kargs):
    stl = searchForSimTool("meltingkim")
    inputs =getSimToolInputs(stl)
    for i,w in widget.inputs.items():
        inputs[i].value = w.value
    r =Run(stl, inputs)
    for outk, out in widget.outputs.items():
        with out:
            print(r.read(outk))
s = WidgetConstructor(schema)
s.RunSimTool = RunSimTool
s.assemble()
s

```

## Create a Sim2l GUI (Generate Code) 


```python
from sim2lbuilder import WidgetConstructor, GetSimtoolDefaultSchema
from simtool import searchForSimTool, getSimToolInputs, Run
schema = GetSimtoolDefaultSchema("meltingkim")
def RunSimTool(widget, *kargs):
    stl = searchForSimTool("meltingkim")
    inputs =getSimToolInputs(stl)
    for i,w in widget.inputs.items():
        inputs[i].value = w.value
    r =Run(stl, inputs)
    for outk, out in widget.outputs.items():
        with out:
            print(r.read(outk))
s = WidgetConstructor(schema, format="file")
s.RunSimTool = RunSimTool
s.assemble()
s

```

## Create a Sim2l GUI (Print Code) 

```python
from sim2lbuilder import WidgetConstructor, GetSimtoolDefaultSchema
from simtool import searchForSimTool, getSimToolInputs, Run
schema = GetSimtoolDefaultSchema("meltingkim")
def RunSimTool(widget, *kargs):
    stl = searchForSimTool("meltingkim")
    inputs =getSimToolInputs(stl)
    for i,w in widget.inputs.items():
        inputs[i].value = w.value
    r =Run(stl, inputs)
    for outk, out in widget.outputs.items():
        with out:
            print(r.read(outk))
s = WidgetConstructor(schema, format="text")
s.RunSimTool = RunSimTool
s.assemble()
s

```

## Create a Sim2l App (Javascript)

```python
from sim2lbuilder import *
schema = GetSimtoolDefaultSchema("introtosimtools")
s = UIDLConstructor(schema, drawer_width=350, width="100%", height="600px")
s.assemble(
    jupyter_notebook_url=jupyter_notebook_url,  
)
```

## Create a Sim2l App - Jupyter widget (ipywidget)


```python
from sim2lbuilder import *
schema = GetSimtoolDefaultSchema("introtosimtools")
s = UIDLConstructor(schema, drawer_width=350, width="100%", height="600px")
s.assemble(
    jupyter_notebook_url=jupyter_notebook_url, 
    uidl_local = True,
    copy_libraries=True,
    widget = False,    
)
