Fix boolean params in web interface by switching to action=store, type=bool

instead of using action=store_true
This commit is contained in:
Florian Festi 2016-06-21 21:51:55 +02:00
parent b5d74c2151
commit 3c5b3147f4
2 changed files with 5 additions and 5 deletions

View File

@ -186,7 +186,7 @@ class Boxes:
"--output", action="store", type=str, default="box.svg",
help="name of resulting file")
self.argparser.add_argument(
"--debug", action="store_true", default=False,
"--debug", action="store", type=bool, default=False,
help="print surrounding boxes for some structures")
self.argparser.add_argument(
"--burn", action="store", type=float, default=0.05,

View File

@ -98,16 +98,16 @@ class BServer:
return ""
row = """<tr><td>%s</td><td>%%s</td><td>%s</td></tr>\n""" % \
(name, a.help or "")
if isinstance(a, argparse._StoreTrueAction):
input = """<input name="%s" type="checkbox" value="%s">""" % \
(name, a.default)
elif (isinstance(a, argparse._StoreAction) and
if (isinstance(a, argparse._StoreAction) and
isinstance(a.type, boxes.ArgparseEdgeType)):
input = a.type.html(name, a.default)
elif a.dest == "layout":
val = a.default.split("\n")
input = """<textarea name="%s" cols="%s" rows="%s">%s</textarea>""" % \
(name, max((len(l) for l in val))+10, len(val)+1, a.default)
elif a.type is bool:
input = """<input name="%s" type="checkbox">""" % \
(name, )
else:
input = """<input name="%s" type="text" value="%s">""" % \
(name, a.default)