我想在 Elm 中创建一个需要 4 个必需输入的表单:
- 3 个浮点值
- 1 个输入可以采用“长”或“短”的值(大概),这将是一个下拉菜单
输入值后,将进行计算,根据这些值产生单行输出。
我有这个作为命令行 Python 程序工作:
#!/usr/bin/env python
from __future__ import print_function
# core
import logging
# pypi
import argh
# local
logging.basicConfig(
format='%(lineno)s %(message)s',
level=logging.WARN
)
def main(direction, entry, swing, atr):
entry = float(entry)
swing = float(swing)
atr = float(atr)
if direction == 'long':
sl = swing - atr
tp = entry + (2 * atr)
elif direction == 'short':
sl = swing + atr
tp = entry - (2 * atr)
print("For {0} on an entry of {1}, SL={2} and TP={3}".format(
direction, entry, sl, tp))
if __name__ == '__main__':
argh.dispatch_command(main)
但想使用 Elm 为它创建一个 Web UI。