Sequence

class visigoth.containers.sequence.Sequence(spacing=20, orientation='vertical')

Construct a container holding multiple elements in a sequence layout

Keyword Arguments
  • spacing (int) – spacing between elements in pixels

  • orientation (str) – vertical|horizontal whether to layout the sequence top-to-bottom or left-to-right

The way you might use me is:

>>> d = Diagram()
>>> s = Sequence()
>>> s.add(Text("Here is some text"))
>>> s.add(Text("Here is some more text"))
>>> d.add(s)
add(element)

Add an element to the sequence to appear after previously added elements

Parameters

element (DiagramElement) – the element to append to the sequence

Example

Screenshot (Link to open SVG for interactive features):

../_images/example18.png

Source Code (Link to Github):


import os
import sys
import argparse

from visigoth import Diagram

from visigoth.containers.sequence import Sequence
from visigoth.containers.box import Box
from visigoth.common.text import Text
from visigoth.common.space import Space

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")

    s0 = Sequence()
    s0.add(Space(0,300))
    s0.add(Text("Left").setLeftJustified()).add(Text("Center")).add(Text("Right").setRightJustified())
    d.add(s0)

    s = Sequence(spacing=20,orientation="horizontal")
    s.add(Box(Text("Red Box"),fill="red")).add(Box(Text("Green Box"),fill="green")).add(Box(Text("Blue Box"),fill="blue"))
    d.add(Box(s,fill="lightgrey"))

    svg = d.draw()

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