<!-- 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 <
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
资源分类:Python库 所属语言:Python 资源全名:scriptedforms-0.8.0.dev2.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
Python库 | scriptedforms-0.8.0.dev2.tar.gz (150个子文件)
Apache-2.0 11KB
Apache-2.0 11KB
setup.cfg 59B
style.css 3KB
style.css 863B
e79bfd88537def476913f3ed52f4f4b3.eot 140KB
.gitignore 16B
variable-table.component.html 4KB
index.html 1KB
doc.component.html 394B
landing-page.component.html 42B
MANIFEST.in 158B
jupyterlab.js 2.18MB
angular.js 1.8MB
0.chunk.js 437KB
scriptedforms.js 273KB
polyfills.js 69KB
misc-vendors.js 65KB
webpack.config.js 2KB
webpack.prod.js 445B
webpack.dev.js 306B
package.json 3KB
tslint.json 3KB
tslint.json 3KB
.angular-cli.json 1KB
package.json 621B
tsconfig.json 462B
tsconfig.spec.json 283B
tsconfig.json 264B
tsconfig.e2e.json 235B
tsconfig.app.json 211B
LICENSE 34KB
LICENSE 34KB
LICENSE 1KB
yarn.lock 270KB
yarn.lock 26KB
README.md 10KB
agree-to-license.md 4KB
watchdog-template.md 790B
watchdog-manage.md 730B
section-button.md 711B
section-output.md 516B
section-live.md 369B
variable-string.md 328B
section-start.md 240B
landing-page.md 16B
PKG-INFO 268B
PKG-INFO 268B
_utilities.py 6KB
process.py 5KB
scriptedforms.py 3KB
run-test.py 2KB
_scriptedforms_handlers.py 2KB
__init__.py 1KB
setup.py 1021B
_version.py 112B
__main__.py 81B
__init__.py 0B
__init__.py 0B
theme.scss 2KB
travis_install.sh 1KB
travis_script.sh 359B
pip-freeze.sh 343B
wait_for_selenium.sh 192B
pypi.sh 83B
selenium.sh 60B
create-form-component-factory.ts 13KB
variable.service.ts 11KB
variable-table.component.ts 6KB
kernel.service.ts 6KB
form-builder.component.ts 6KB
code.component.ts 6KB
file.service.ts 6KB
app.component.ts 6KB
button.component.ts 5KB
live.component.ts 5KB
variable-base.component.ts 5KB
watchdog.service.ts 5KB
dropdown.component.ts 4KB
toolbar-base.component.ts 4KB
section-file-change.component.ts 4KB
widget.ts 3KB
phosphor-angular-loader.ts 3KB
variable-string.spec.ts 3KB
start.component.ts 3KB
dev.ts 3KB
form.service.ts 3KB
app.module.ts 3KB
section-button.spec.ts 3KB
toolbar-button.component.ts 3KB
variables.module.ts 3KB
output.component.ts 3KB
watchdog-test.spec.ts 3KB
initialisation.service.ts 3KB
jupyter-session-connect.ts 3KB
slider.component.ts 3KB
number.component.ts 2KB
string.component.ts 2KB
material.module.ts 2KB
app-error-handler.ts 2KB
共 150 条
- 1
- 2
资源评论
挣扎的蓝藻
- 粉丝: 14w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功