Graphics.Text Justification Examples

These examples show how the Text object from Graphics use xJustification and yJustification.

In [1]:
from Graphics import *

Here we show examples of all combinations of justification:

In [2]:
for x in ["left", "center", "right"]:
    for y in ["top", "center", "bottom"]:
        canvas = Canvas(100, 100)
        point = Text((50,50), "+")
        point.color = Color(0,0,0)
        point.draw(canvas)

        t1 = Text((50,50), "X1\nXX2\nXXX3")
        t1.yJustification = y
        t1.xJustification = x
        calico.display("xJustification: '%s', yJustification: '%s'" % (x, y), t1.draw(canvas))
xJustification: 'left', yJustification: 'top'
xJustification: 'left', yJustification: 'center'
xJustification: 'left', yJustification: 'bottom'
xJustification: 'center', yJustification: 'top'
xJustification: 'center', yJustification: 'center'
xJustification: 'center', yJustification: 'bottom'
xJustification: 'right', yJustification: 'top'
xJustification: 'right', yJustification: 'center'
xJustification: 'right', yJustification: 'bottom'
In [ ]: