Simtool builder
Project description
Sim2lBuilder Stats
Latest Release | |
PyPI Downloads |
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
pip install sim2lbuilder
Usage
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)
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)
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)
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)
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)
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,
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file sim2lbuilder-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: sim2lbuilder-0.0.7-py3-none-any.whl
- Upload date:
- Size: 29.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/6.0.0 pkginfo/1.8.2 requests/2.28.2 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91c442949418d4550cca33995809f96ebf610c597065ce66ad9e3fc6de7169cb |
|
MD5 | fbbd183d0da2e40ed10b3a6b9443c262 |
|
BLAKE2b-256 | 08128e411f254041402ff20677dc85b7129b0950c41fbac047bcca480e4596e1 |