Next / Previous / Contents / TCC Help System / NM Tech homepage

6.10. The canvas text object

You can display one or more lines of text on a canvas C by creating a text object:

    id = C.create_text ( x, y, option, ... )

This returns the object ID of the text object on canvas C. Options include:

anchorThe default is anchor=CENTER, meaning that the text is centered vertically and horizontally around position (x, y). See Section 4.5, “Anchors” for possible values. For example, if you specify anchor=SW, the text will be positioned so its lower left corner is at point (x, y).
fillThe default text color is black, but you can render it in any color by setting the fill option to that color. See Section 4.3, “Colors”.
fontIf you don't like the default font, set this option to any font value. See Section 4.4, “Type fonts”.
justifyFor multi-line textual displays, this option controls how the lines are justified: LEFT (the default), CENTER, or RIGHT.
stippleA bitmap indicating how the text will be stippled. Default is stipple="", which means solid. A typical value would be stipple="gray25". See Section 4.7, “Bitmaps”.
tagsThe tags to be associated with the object, as a sequence of strings. See Section 6.1.4, “Canvas tags”.
textThe text to be displayed in the object, as a string. Use newline characters ("\n") to force line breaks.
widthIf you don't specify a width option, the text will be set inside a rectangle as long as the longest line. However, you can also set the width option to a dimension, and each line of the text will be broken into shorter lines, if necessary, or even broken within words, to fit within the specified width. See Section 4.1, “Dimensions”.