<!-- markdownlint-disable MD033 -->
# Scripted Forms [![Build Status](https://travis-ci.org/SimonBiggs/scriptedforms.svg?branch=master)](https://travis-ci.org/SimonBiggs/scriptedforms) [![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/SimonBiggs/scriptedforms-examples/master)
Making GUIs easy for everyone on your team.
The primary benefit is that front ends for Python code become easily accessible
to everyone on your team. Easy to use, easy to update, easy to extend, and easy
to understand.
* Quickly create live-update GUIs for Python packages using Markdown and a few custom HTML elements.
* Just write in markdown + variables / UI types
* Based on Jupyter
## Quick start
If you would like to take scriptedforms for a spin you will need Python. If you don't have Python on your computer I recommend using Anaconda Python (https://www.anaconda.com/download/).
After you have python you can then install ScriptedForms by typing the following into a terminal (or command prompt):
```bash
pip install scriptedforms
```
Then create a markdown file called `quick-start.md` using any plaintext editor (such as
[Visual Studio Code](https://code.visualstudio.com/)) within your terminal's current directory.
Make the contents be the following:
~~~markdown
# An example
<section-live>
<variable-string>your_name</variable-string>
```python
print('Hello {}!'.format(your_name))
```
</section-live>
~~~
Then run the following in your terminal
```bash
scriptedforms quick-start.md
```
If everything worked, a Scripted Form should open within your default browser.
You should be able to type your name into the form and see the code field live
update with each key stroke:
<p align="center">
<img src="./images/quick-start.png">
</p>
Now within `quick-start.md` edit the markdown file by changing
```markdown
# An example
```
to
```markdown
# The form updates when I change it
```
and then press save. The form in the browser should then update to match what
you just wrote.
### Plotting and slider example
If you want to be a bit more adventurous see what happens if you add the
following to the end of the your `quick-start.md` file (or any other
ScriptedForm):
~~~markdown
#### Example slider use case
Using the slider and live sections combined with matplotlib plots you can
produce utilities like the following:
<section-start>
```python
t = np.linspace(-2*np.pi, 2*np.pi, 500)
omega = np.ones(2)
```
</section-start>
<section-live>
Angular frequencies ($\omega$):
<variable-slider name="$\omega [0]$" min="0" max="6" step="0.1">omega[0]</variable-slider>
<variable-slider name="$\omega [1]$" min="0" max="6" step="0.1">omega[1]</variable-slider>
```python
plt.figure(figsize=(5*1.618,5))
oscillation = np.sin(t[:, np.newaxis] * omega[np.newaxis, :])
summation = np.sum(oscillation, axis=1)
plt.plot(t, oscillation)
plt.plot(t, summation)
plt.xlim([-2*np.pi, 2*np.pi])
plt.ylim([-2.4, 2.4])
plt.title('Two sin curves and their summation')
plt.legend([
r'$\omega [0] = {0:0.1f}$'.format(omega[0]),
r'$\omega [1] = {0:0.1f}$'.format(omega[1]),
'Summation'], loc='upper right')
plt.xlabel('time (seconds)')
plt.ylabel(r'$sin(\omega \times t)$');
```
</section-live>
~~~
This should produce what is seen in the following screenshot:
<a href="https://mybinder.org/v2/gh/SimonBiggs/scriptedforms-examples/master">
<p align="center">
<img src="./images/detailed.png">
</p>
</a>
[Click here](https://mybinder.org/v2/gh/SimonBiggs/scriptedforms-examples/master) to see a live version of this example on mybinder.org. This will run slower online on that server than when you are using it locally.
### More features
For a markdown file that presents the majority of the features of scriptedforms
see
[detailed.md](https://raw.githubusercontent.com/SimonBiggs/scriptedforms/master/example/example/detailed.md).
Try writing some of the contents of that file into a ScriptedForm to see how
they work.
## Security notice
Be aware that ScriptedForms uses the [Jupyter Notebook Server security model](http://jupyter-notebook.readthedocs.io/en/stable/security.html#security-in-the-jupyter-notebook-server). When a user has access to the forms via the localhost web interface, should they have sufficient know how, they also have the ability to run arbitrary Python code without limitations.
By default only users on the local machine will be able to access the Jupyter Notebook Server which means if you trust a user to run code on their own machine then allowing them to use ScriptedForms will not cause issue. Only override these default settings if you understand and accept the security implications.
Furthermore do not run a scripted form unless you trust its origin. Given the reactive nature of ScriptedForms, code within the markdown template can run on form opening, as well as during usage.
## Example that can be used as a template for deployment
This is designed to be used as a quick and easy GUI for python packages. An
example package that creates a console script that then uses scriptedforms to
boot up a GUI can be found within the [example](./example) directory.
Within the [`README.md`](./example/README.md) file of that directory there is an
explanation of how you might go about deploying your utility with its new GUI.
## [Optional] Installing the Jupyter Server extension
ScriptedForms can also be installed as a [Jupyter Server extension](http://jupyter-notebook.readthedocs.io/en/stable/examples/Notebook/Distributing%20Jupyter%20Extensions%20as%20Python%20Packages.html#Enable-a-Server-Extension). Eventually this should allow the use of ScriptedForms with tools such as [JupyterHub](http://jupyterhub.readthedocs.io/en/latest/). This part of ScriptedForms is still a work in progress but if you want to give it a try then make sure you have at least version `0.5.15` of ScriptedForms and then run:
```bash
jupyter serverextension enable --py scriptedforms
```
Then to start ScriptedForms using its Jupyter Server extension run the following
```bash
jupyter notebook --NotebookApp.default_url=/scriptedforms/use/quick-start.md
```
## [Advanced users only] Installing scriptedforms from the GitHub source
The majority of users will not need to pay attention to this section.
For those who wish to build scriptedforms from the source provided within this
repository, instead of using pypi, the javascript bundle will need to be built.
To do this you will need to
[install `yarn`](https://yarnpkg.com/lang/en/docs/install/) and then run the
following in the
[directory containing the `package.json` file](./scriptedforms):
```bash
yarn
yarn build
yarn pip:install
```
This will install the node packages, build the javascript files and then run
`pip install -e .` to install the python package.
## Software license agreement
Scripted Forms -- Making GUIs easy for everyone on your team.
Copyright (C) 2017 Simon Biggs
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version (the "AGPL-3.0+").
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License and the additional terms for more
details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
ADDITIONAL TERMS are also included as allowed by Section 7 of the GNU
Affrero General Public License. These aditional terms are Sections 1, 5,
6, 7, 8, and 9 from the Apache License, Version 2.0 (the "Apache-2.0")
where all references to the definition "License" are instead defined to
mean the AGPL-3.0+.
You should have received a copy of the Apache-2.0 along with this
program. If not, see <
挣扎的蓝藻
- 粉丝: 14w+
- 资源: 15万+
最新资源
- 三相共直流母线式光储VSG 同步机 构网型 组网型逆变器 仿真包含前级光伏PV与Boost的扰动观察法最大功率追踪,共直流母线式储能Buck-boost变器,采用电压电流双闭环控制 三相VSG 同步
- 光伏MPPT同步发电机(VSG)并网仿真模型 结构:前级光伏板采用扰动观察法最大功率跟踪给定值,然后将该功率通过直流母线电容电压进行功率解耦并经过逆变器输送给右侧的负载和电网 控制:光伏Boost采用
- 电动车之王特斯拉二手车选购指南
- 光伏储能同步发电机VSG并网仿真模型C 光伏阵列搭建的光伏电池模型 光伏:采用扰动观察法最大功率点MPPT跟踪控制 储能:蓄电池充放电控制,双向Buck Boost变器,采用直流母线电压外环控制稳定直
- 改进滑膜控制与传统控制的永磁同步电机PMSM仿真模型 学习资料: ①与仿真完全对应的29页Word文档详细说明和4页设计说明 ②(PI、最优滑膜、改进滑膜)三种控制仿真模型 ③录制好的导出波形
- 在MATLAB中发现集群并使用集群配置文件.pdf
- 精品二手车检测方法实战
- 风储惯量调频仿真模型,风电调频,一次调频,四机两区系统,采用频域模型法使得风电渗透率25%,附加惯性控制,储能附加下垂控制,参与系统一次调频,系统频率特性优 有SOC特性 特点,风储联合仿真速度很快
- python+Django+MySQL实现学生管理系统
- 基于PI+重复控制的有源电力滤波器谐波抑制策略 ①APF有源电力滤波器 ②无功补偿 ③PI+重复控制(电流环重复控制) ④THD小于1%,谐波抑制 附带搭建仿真过程参考的文献(最后一张图) 2018b
- https://test-mp-v4.csdn.net/mp-blog/creation/editor
- PowerBI-svg 目标达成率
- 三相四桥臂逆变器MATLAB Simulink仿真模型,接不平衡负载时的调制算法 接非线性负载时的多PR控制器并联算法 提供仿真模型、设计报告及参考文献
- 高斯变迹光栅滤波器模型建立,fdtd模型+参考文献
- Golang之敏感词过滤器的设计与实现
- 基于微信原生开发的微信商城项目
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈