TextAnnotation module
- class lys.widgets.canvas.interface.TextAnnotation.TextAnnotation(canvas, text, pos, axis)[source]
Bases:
AnnotationDataInterface to access text annotations in canvas.
TextAnnotation is usually generated by addText method in canvas.
- Parameters:
canvas (Canvas) – canvas to which the text annotation is added.
text (str) – The text of the annotation.
pos (length 2 sequence) – The psition of the annotation in the form of (x,y).
axis ('BottomLeft', 'BottomRight', 'TopLeft', or 'TopRight') – The axis to which the text annotation is added.
Example:
from lys import display g = display() line = g.addText('test')
- edited
Pyqtsignal that is emitted when the text is edited.
- getBoxStyle()[source]
Get the style of the bounding box.
- Returns:
The style of the bounding box. See
setBoxStyle()- Return type:
str
- getFont()[source]
Get the font of the label.
- Parameters:
axis ('Left' or 'Right' or 'Top' or 'Bottom') – The axis.
- Returns:
The information of font. See
setFont()- Return type:
dict
- getPosition()[source]
Get the position of the annotation.
- Returns:
The position of the annotation.
- Return type:
length 2 sequence
- getText()[source]
Get the text of the annotation.
- Returns:
The text of the annotation.
- Return type:
str
- getTransform()[source]
Get the transformation of the annotation.
- Returns:
The transformation string.
- Return type:
str
- setBoxColor(faceColor, edgeColor)[source]
Set the color of the bounding box.
- Parameters:
faceColor – The face color in the form of color string such as #111111
edgeColor – The edge color in the form of color string such as #111111
- setBoxStyle(style)[source]
Set the style of the bounding box.
- Parameters:
style (str) – ‘none’, ‘square’, ‘circle’, ‘round’, ‘round4’, ‘larrow’, ‘rarrow’, ‘darrow’, ‘roundtooth’, or ‘sawtooth’
- setFont(fname, size=10, color='black')[source]
Set the font of the annotation.
- Parameters:
family (str) – The name of the font.
size (int) – The size of the font.
color (str) – The color of the font such as ‘#111111’.
- setPosition(pos)[source]
Set the position of the annotation.
- Parameters:
pos (length 2 sequence) – The position of the annotation.
- setText(text)[source]
Set the text of the annotation.
- Parameters:
text (str) – The text of the annotation.
- setTransform(transformation)[source]
Set the transformation of the annotation.
When the transformation is ‘axes’, the annotation is fixed in the canvas.
When the transformation is ‘data’, the position of the annotation is changed when the view range of the canvas is changed.
- Parameters:
transformation ('axes' or 'data') – The transformation.