Put arguments into groups and use them to display them in the web interface
This commit is contained in:
parent
9095c3934f
commit
5a721df82b
|
@ -191,32 +191,37 @@ class Boxes:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.formats = formats.Formats()
|
self.formats = formats.Formats()
|
||||||
self.argparser = ArgumentParser(description=self.__doc__)
|
self.argparser = ArgumentParser(description=self.__doc__)
|
||||||
self.argparser.add_argument(
|
self.argparser._action_groups[1].title = "Generator Settings"
|
||||||
|
fingergroup = self.argparser.add_argument_group(
|
||||||
|
"Finger Joint Settings")
|
||||||
|
fingergroup.add_argument(
|
||||||
"--fingerjointfinger", action="store", type=float, default=1.0,
|
"--fingerjointfinger", action="store", type=float, default=1.0,
|
||||||
help="width of the fingers in multiples of thickness")
|
help="width of the fingers in multiples of thickness")
|
||||||
self.argparser.add_argument(
|
fingergroup.add_argument(
|
||||||
"--fingerjointspace", action="store", type=float, default=1.0,
|
"--fingerjointspace", action="store", type=float, default=1.0,
|
||||||
help="width of the space between fingers in multiples of thickness")
|
help="width of the space between fingers in multiples of thickness")
|
||||||
self.argparser.add_argument(
|
fingergroup.add_argument(
|
||||||
"--fingerjointsurrounding", action="store", type=float, default=1.0,
|
"--fingerjointsurrounding", action="store", type=float, default=1.0,
|
||||||
help="amount of space needed at the end in multiples of normal spaces")
|
help="amount of space needed at the end in multiples of normal spaces")
|
||||||
self.argparser.add_argument(
|
defaultgroup = self.argparser.add_argument_group(
|
||||||
|
"Default Settings")
|
||||||
|
defaultgroup.add_argument(
|
||||||
"--thickness", action="store", type=float, default=4.0,
|
"--thickness", action="store", type=float, default=4.0,
|
||||||
help="thickness of the material")
|
help="thickness of the material")
|
||||||
self.argparser.add_argument(
|
defaultgroup.add_argument(
|
||||||
"--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(
|
defaultgroup.add_argument(
|
||||||
"--format", action="store", type=str, default="svg",
|
"--format", action="store", type=str, default="svg",
|
||||||
choices=self.formats.getFormats(),
|
choices=self.formats.getFormats(),
|
||||||
help="format of resulting file")
|
help="format of resulting file")
|
||||||
self.argparser.add_argument(
|
defaultgroup.add_argument(
|
||||||
"--debug", action="store", type=bool, 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(
|
defaultgroup.add_argument(
|
||||||
"--reference", action="store", type=float, default=100,
|
"--reference", action="store", type=float, default=100,
|
||||||
help="print reference rectangle with given length")
|
help="print reference rectangle with given length")
|
||||||
self.argparser.add_argument(
|
defaultgroup.add_argument(
|
||||||
"--burn", action="store", type=float, default=0.05,
|
"--burn", action="store", type=float, default=0.05,
|
||||||
help="burn correction in mm (bigger values for tighter fit)")
|
help="burn correction in mm (bigger values for tighter fit)")
|
||||||
|
|
||||||
|
|
|
@ -142,15 +142,17 @@ flex cuts, holes and slots for screws and more high level functions.
|
||||||
<h2 style="font-size: 1em; margin: 0px; "> <a href="/">generators</a></h2><h2 style="margin: 0px 0px 0px 20px;" > <span style="margin-right: 10px;"> >> <span>""", name, """</h2>
|
<h2 style="font-size: 1em; margin: 0px; "> <a href="/">generators</a></h2><h2 style="margin: 0px 0px 0px 20px;" > <span style="margin-right: 10px;"> >> <span>""", name, """</h2>
|
||||||
<p>""", box.__doc__ or "", """</p>
|
<p>""", box.__doc__ or "", """</p>
|
||||||
<form action="%s" method="GET" target="_blank">
|
<form action="%s" method="GET" target="_blank">
|
||||||
<table>
|
|
||||||
""" % (action)]
|
""" % (action)]
|
||||||
for a in box.argparser._actions:
|
for group in box.argparser._action_groups[2:] + box.argparser._action_groups[:2]:
|
||||||
if a.dest in ("input", "output"):
|
if not group._group_actions:
|
||||||
continue
|
continue
|
||||||
result.append(self.arg2html(a))
|
result.append("<h3>%s</h3>\n<table>\n" % group.title)
|
||||||
if a.dest == "burn":
|
for a in group._group_actions:
|
||||||
result.append("</table>\n<hr>\n<table>\n")
|
if a.dest in ("input", "output"):
|
||||||
result.append("""</table>
|
continue
|
||||||
|
result.append(self.arg2html(a))
|
||||||
|
result.append("</table>")
|
||||||
|
result.append("""
|
||||||
<p><button name="render" value="1">Generate</button></p>
|
<p><button name="render" value="1">Generate</button></p>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue