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", "--output", action="store", type=str, default="box.svg",
help="name of resulting file") help="name of resulting file")
self.argparser.add_argument( self.argparser.add_argument(
"--debug", action="store_true", default=False, "--debug", action="store", type=bool, default=False,
help="print surrounding boxes for some structures") help="print surrounding boxes for some structures")
self.argparser.add_argument( self.argparser.add_argument(
"--burn", action="store", type=float, default=0.05, "--burn", action="store", type=float, default=0.05,

View File

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