From 5a721df82bd116ad87134190e0bf249d96e02d05 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Sun, 30 Oct 2016 15:27:16 +0100 Subject: [PATCH] Put arguments into groups and use them to display them in the web interface --- boxes/__init__.py | 23 ++++++++++++++--------- scripts/boxesserver | 16 +++++++++------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/boxes/__init__.py b/boxes/__init__.py index fdeaf7d..128176d 100755 --- a/boxes/__init__.py +++ b/boxes/__init__.py @@ -191,32 +191,37 @@ class Boxes: def __init__(self): self.formats = formats.Formats() 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, help="width of the fingers in multiples of thickness") - self.argparser.add_argument( + fingergroup.add_argument( "--fingerjointspace", action="store", type=float, default=1.0, 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, 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, help="thickness of the material") - self.argparser.add_argument( + defaultgroup.add_argument( "--output", action="store", type=str, default="box.svg", help="name of resulting file") - self.argparser.add_argument( + defaultgroup.add_argument( "--format", action="store", type=str, default="svg", choices=self.formats.getFormats(), help="format of resulting file") - self.argparser.add_argument( + defaultgroup.add_argument( "--debug", action="store", type=bool, default=False, help="print surrounding boxes for some structures") - self.argparser.add_argument( + defaultgroup.add_argument( "--reference", action="store", type=float, default=100, help="print reference rectangle with given length") - self.argparser.add_argument( + defaultgroup.add_argument( "--burn", action="store", type=float, default=0.05, help="burn correction in mm (bigger values for tighter fit)") diff --git a/scripts/boxesserver b/scripts/boxesserver index 16b6339..285080c 100755 --- a/scripts/boxesserver +++ b/scripts/boxesserver @@ -142,15 +142,17 @@ flex cuts, holes and slots for screws and more high level functions.

generators

>> """, name, """

""", box.__doc__ or "", """

- """ % (action)] - for a in box.argparser._actions: - if a.dest in ("input", "output"): + for group in box.argparser._action_groups[2:] + box.argparser._action_groups[:2]: + if not group._group_actions: continue - result.append(self.arg2html(a)) - if a.dest == "burn": - result.append("
\n
\n\n") - result.append("""
+ result.append("

%s

\n\n" % group.title) + for a in group._group_actions: + if a.dest in ("input", "output"): + continue + result.append(self.arg2html(a)) + result.append("
") + result.append("""