Grid

class visigoth.containers.grid.Grid(stroke=None, stroke_width=0, padding=10, fill=None)

A grid layout

Keyword Arguments:
 
  • stroke_width (int) – width of the grid lines in pixels
  • stroke (str) – colour of the grid lines
  • padding (int) – width of the cell padding in pixels
  • fill (str) – fill colour for the cells

Note: use the add method to add elements to the grid

add(row, col, element)

Add an element into the grid

Parameters:
  • row (int) – the number of the row (numbering starts at 0, top to bottom)
  • col (int) – the number of the column (numbering starts at 0, left to right)
  • element (DiagramElement) – the element to add

Example

(Link to open example in new tab):

Source Code (Link to Github):

# -*- coding: utf-8 -*-

from visigoth import Diagram
from visigoth.containers import Grid
from visigoth.common import Text

d = Diagram()

d.add(Text("Simple Grid"))

g = Grid()
g.add(0,0,Text("Top-Left Cell in Grid"))
g.add(1,0,Text("Bottom-Left").setRightJustified())
g.add(0,1,Text("Top-Right").setLeftJustified())
g.add(1,1,Text("Bottom-Right Cell in Grid"))
d.add(g)

html = d.draw(format="html")

f = open("example.html", "w")
f.write(html)
f.close()