diff --git a/boxes/__init__.py b/boxes/__init__.py index 9b79b59..7d400a6 100755 --- a/boxes/__init__.py +++ b/boxes/__init__.py @@ -285,6 +285,7 @@ class Boxes: webinterface = True ui_group = "Misc" + UI = "" description: str = "" # Markdown syntax is supported diff --git a/boxes/generators/gridfinitytraylayout.py b/boxes/generators/gridfinitytraylayout.py index 883bc6d..d0a2253 100644 --- a/boxes/generators/gridfinitytraylayout.py +++ b/boxes/generators/gridfinitytraylayout.py @@ -1,10 +1,10 @@ import boxes from boxes import Boxes -from boxes.generators.traylayout import TrayLayout, TrayLayout2 +from boxes.generators.traylayout import TrayLayout from boxes.Color import Color from boxes import restore -class GridfinityTrayLayout(TrayLayout2): +class GridfinityTrayLayout(TrayLayout): """A Gridfinity Tray Generator based on TrayLayout""" description = """ diff --git a/boxes/generators/traylayout.py b/boxes/generators/traylayout.py index 02b96db..b119456 100644 --- a/boxes/generators/traylayout.py +++ b/boxes/generators/traylayout.py @@ -19,7 +19,7 @@ import boxes from boxes import * -class TrayLayout(Boxes): +class TrayLayoutFile(Boxes): """Generate a layout file for a typetray.""" # This class generates the skeleton text file that can then be edited # to describe the actual box @@ -29,7 +29,7 @@ The layout is based on a grid of sizes in x and y direction. Choose how many distances you need in both directions. The actual sizes and all other settings can be entered in the second step.""" - webinterface = True + webinterface = False ui_group = "Tray" @@ -83,13 +83,13 @@ The actual sizes and all other settings can be entered in the second step.""" f.write(str(self)) -class TrayLayout2(Boxes): +class TrayLayout(Boxes): """Generate a typetray from a layout file.""" # This class reads in the layout either from a file (with --input) or # as string (with --layout) and turns it into a drawing for a box. - webinterface = True + ui_group = "Tray" description = """This is a two step process. This is step 2. Edit the layout text graphics to adjust your tray. @@ -98,19 +98,19 @@ vertical bars representing the walls with a space character to remove the walls. You can replace the space characters representing the floor by a "X" to remove the floor for this compartment. """ - def __init__(self, input=None, webargs=False) -> None: - Boxes.__init__(self) + def __init__(self) -> None: + super().__init__() self.addSettingsArgs(boxes.edges.FingerJointSettings) - self.buildArgParser("h", "hi", "outside") - if not webargs: + self.buildArgParser("h", "hi", "outside", "sx", "sy") + if self.UI == "web": + self.argparser.add_argument( + "--layout", action="store", type=str, default="") + else: self.argparser.add_argument( "--input", action="store", type=argparse.FileType('r'), default="traylayout.txt", help="layout file") self.layout = None - else: - self.argparser.add_argument( - "--layout", action="store", type=str, default="") def vWalls(self, x: int, y: int) -> int: """Number of vertical walls at a crossing.""" diff --git a/scripts/boxesserver b/scripts/boxesserver index e066cea..b43b7d0 100755 --- a/scripts/boxesserver +++ b/scripts/boxesserver @@ -113,11 +113,11 @@ class BServer: def __init__(self, url_prefix="", static_url="static") -> None: self.boxes = {b.__name__: b for b in boxes.generators.getAllBoxGenerators().values() if b.webinterface} - self.boxes['TrayLayout2'] = boxes.generators.traylayout.TrayLayout2 # type: ignore # no attribute "traylayout" self.groups = boxes.generators.ui_groups self.groups_by_name = boxes.generators.ui_groups_by_name for name, box in self.boxes.items(): + box.UI = "web" self.groups_by_name.get(box.ui_group, self.groups_by_name["Misc"]).add(box) @@ -351,8 +351,6 @@ class BServer:
\n