Box

class visigoth.containers.box.Box(element, margin=2, stroke_width=2, stroke='grey', padding=2, fill=None)

Wrap an element with a surrounding box

Parameters

element (DiagramElement) – element to wrap

Keyword Arguments
  • margin (int) – width of the margin in pixels

  • stroke_width (int) – width of the border in pixels

  • stroke (str) – colour of the border

  • padding (int) – width of the padding in pixels

  • fill (str) – fill colour for the box

Example

Screenshot (Link to open SVG for interactive features):

../_images/example14.png

Source Code (Link to Github):


import os
import sys
import argparse

from visigoth import Diagram

from visigoth.containers.box import Box
from visigoth.common.text import Text

if __name__ == "__main__":

    parser = argparse.ArgumentParser()
    parser.add_argument("--outpath", help="path for output SVG", default="example.svg")
    args = parser.parse_args()

    d = Diagram(fill="white")

    d.add(Text("Some Text"))
    d.add(Box(Text("Some Text in an Orange Box"),fill="orange",stroke="darkred",stroke_width=4,margin=10,padding=5))

    svg = d.draw()

    f = open(args.outpath, "wb")
    f.write(svg)
    f.close()