chaco.label module

Defines the Label class.

class chaco.label.Label(**traits)

Bases: traits.has_traits.HasTraits

A label used by overlays.

Label is not a Component; it’s just an object encapsulating text settings and appearance attributes. It can be used by components that need text labels to store state, perform layout, and render the text.

bgcolor = transparent_color_trait

The background color of the label.

border_color = black_color_trait

The color of the border.

border_visible = Bool(True)

Whether or not the border is visible

border_width = Int(0)

The width of the label border. If it is 0, then it is not shown.

color = black_color_trait

The color of the label text.

draw(gc)

Draws the label.

This method assumes the graphics context has been translated to the correct position such that the origin is at the lower left-hand corner of this text label’s box.

font = KivaFont("modern 10")

The font of the label text.

get_bounding_box(gc)

Returns a rectangular bounding box for the Label as (width,height).

get_bounding_poly(gc)

Returns a list [(x0,y0), (x1,y1),…] of tuples representing a polygon that bounds the label.

get_rotation_matrix()
get_width_height(gc)

Returns the width and height of the label, in the rotated frame of reference.

line_spacing = Int(5)

Number of pixels of spacing between lines of text.

margin = Int(2)

Number of pixels of margin around the label, for both X and Y dimensions.

max_width = Float(0.0)

Number of pixels to limit the width of the label to. Lines which are too long will be broken to fit on word boundaries. Line width is calculated without considering the value of margin. A max_width of 0.0 means that lines will not be broken.

rotate_angle = Float(0)

The angle of rotation of the label.

text = Str

The label text. Carriage returns (n) are always connverted into line breaks.