From e32a314c81521cd50a9ed3e912c48afaf909cbec Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Tue, 29 Mar 2016 22:10:54 +0200 Subject: [PATCH] Add template for writing generators --- boxes/generators/_template.py | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 boxes/generators/_template.py diff --git a/boxes/generators/_template.py b/boxes/generators/_template.py new file mode 100644 index 0000000..8fead5a --- /dev/null +++ b/boxes/generators/_template.py @@ -0,0 +1,61 @@ +#!/usr/bin/python3 +# Copyright (C) 2013-2016 Florian Festi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from boxes import * + +class Box(Boxes): + """DESCRIPTION""" + def __init__(self): + Boxes.__init__(self) + # remove cli params you do not need + self.buildArgParser("x", "sx", "y", "sy", "h", "hi") + # Add non default cli params if needed (see argparse std lib) + self.argparser.add_argument( + "--XX", action="store", type=float, default=0.5, + help="DESCRIPTION") + + + def render(self): + # adjust to the variables you want in the local scope + x, y, h = self.x, self.y, self.h + t = self.thickness + # Calculate canvas size and pass as width and height + self.open(width=x+y+40, height=y+2*h+50) + + # Change settings of default edges if needed. E.g.: + self.edges["f"].settings.setValues(self.thickness, space=3, finger=3, + surroundingspaces=1) + # Create new Edges here if needed E.g.: + s = edges.FingerJointSettings(self.thickness, relative=False, + space = 10, finger=10, height=10, + width=self.thickness) + p = edges.FingerJointEdge(self, s) + p.char = "p" + self.addPart(p) + + + # render your parts here + + + self.close() + +def main(): + b = Box() + b.parseArgs() + b.render() + +if __name__ == '__main__': + main()