Text frames

createPathText

createPathText(x, y, "textbox", "beziercurve", ["name"]) -> string

Creates a new pathText by merging the two objects "textbox" and "beziercurve" and returns its name. The coordinates are given in the current measurement unit of the document (see UNIT constants). "name" should be a unique identifier for the object because you need this name for further access to that object. If "name" is not given Scribus will create one for you.

May raise NameExistsError if you explicitly pass a name that's already used. May raise NotFoundError if one or both of the named base object don't exist.

createText

createText(x, y, width, height, ["name"]) -> string

Creates a new text frame on the actual page and returns its name. The coordinates are given in the actual measurement unit of the document (see UNIT constants). "name" should be a unique identifier for the object because you need this name for further referencing of that object. If "name" is not given Scribus will create one for you.

May raise NameExistsError if you explicitly pass a name that's already used.

dehyphenateText

dehyphenateText(["name"]) -> bool

Does dehyphenation on text frame "name". If "name" is not given the currently selected item is used.

May raise WrongFrameTypeError if the target frame is not a text frame

deleteText

deleteText(["name"])

Deletes any text in the text frame "name". If there is some text selected, only the selected text will be deleted. If "name" is not given the currently selected item is used.

getAllText

getAllText(["name"]) -> string

Returns the text of the text frame "name" and of all text frames which are linked with this frame. If this textframe has some text selected, the selected text is returned. If "name" is not given the currently selected item is used.

getCellText

getCellText(row, column, ["name"]) -> string

Returns the text content of the cell at "row", "column" in the table "name". If cell has some text selected, the selected text is returned. If "name" is not given the currently selected item is used.

May throw ValueError if the cell does not exist.

getColumnGap

getColumnGap(["name"]) -> float

Returns the column gap size of the text frame "name" expressed in points. If "name" is not given the currently selected item is used.

getColumns

getColumns(["name"]) -> integer

Gets the number of columns of the text frame "name". If "name" is not given the currently selected item is used.

getFirstLineOffset

getFirstLineOffset(["name"]) -> integer

Gets the offset of the first line of text inside text frame "name". If "name" is not given the currently selected item is used.

getFirstLinkedFrame

getFirstLinkedFrame(item: str = None) -> str

Return the first text frame in the chain.

If "name" is not given the currently selected item is used.

getFont

getFont(["name"]) -> string

Returns the font name for the text frame "name". If this text frame has some text selected the value assigned to the first character of the selection is returned. If "name" is not given the currently selected item is used.

getFontFeatures

getFontFeatures(["name"]) -> string

Returns the font features for the text frame "name". If this text frame has some text selected the value assigned to the first character of the selection is returned. If "name" is not given the currently selected item is used.

getFontSize

getFontSize(["name"]) -> float

Returns the font size in points for the text frame "name". If this text frame has some text selected the value assigned to the first character of the selection is returned. If "name" is not given the currently selected item is used.

getFrameText

getFrameText(["name"]) -> string

Returns the text visible in text frame "name". If this text frame has some text selected, the selected text is returned. If "name" is not given the currently selected item is used.

This function returns only the text visible in specified frame. If you need to retrieve the text contained in a text chain, use getAllText() instead.

As this function depends on text layout being up-to-date, you may need to call layoutText() or layoutTextChain() before calling this function in order to get expected result.

getLastLinkedFrame

getLastLinkedFrame(item: str = None) -> str

Return the last text frame in the chain.

If "name" is not given the currently selected item is used.

getLineSpacing

getLineSpacing(["name"]) -> float

Returns the line spacing ("leading") of the text frame "name" expressed in points. If "name" is not given the currently selected item is used.

getLineSpacingMode

getLineSpacingMode(["name"]) -> float

Returns the line spacing mode of the text frame "name". If "name" is not given the currently selected item is used.

getNextLinkedFrame

getNextLinkedFrame(item: str = None) -> str

Return the next text frame in the chain or None if specified frame is the last frame in the chain.

If "name" is not given the currently selected item is used.

getPrevLinkedFrame

getPrevLinkedFrame(item: str = None) -> str

Return the previous text frame in the chain or None if specified frame is the first frame in the chain.

If "name" is not given the currently selected item is used.

getText

getText(["name"]) -> string

Deprecated. Use getFrameText() instead.

getTextColor

getTextColor(["name"]) -> string

Returns the name of the text color used for text frame "name". If this text frame has some text selected the value assigned to the first character of the selection is returned. If "name" is not given the currently selected item is used.

getTextDistances

getTextDistances(["name"]) -> tuple

Returns the text distances of the text frame "name" expressed in points. The distances are returned as a tuple like (left, right, top, bottom). If "name" is not given the currently selected item is used.

getTextLength

getTextLength(["name"]) -> integer

Returns the length of the text in the text frame "name". If "name" is not given the currently selected item is used.

getTextLines

getTextLines(["name"]) -> integer

Returns the number of lines of the text in the text frame "name". If "name" is not given the currently selected item is used.

As this function depends on text layout being up-to-date, you may need to call layoutText() or layoutTextChain() before calling this function in order to get expected result.

getTextShade

getTextShade(["name"]) -> integer

Returns the shade of text color used for text frame "name". If this text frame has some text selected the value assigned to the first character of the selection is returned. If "name" is not given the currently selected item is used.

getTextVerticalAlignment

getTextVerticalAlignment(["name"]) -> integer

Gets the vertical alignment of text inside text frame "name". If "name" is not given the currently selected item is used.

hyphenateText

hyphenateText(["name"]) -> bool

Does hyphenation on text frame "name". If "name" is not given the currently selected item is used.

May raise WrongFrameTypeError if the target frame is not a text frame

insertHTMLText

insertHTMLText("file", ["name"])

Inserts the text from "file" into the text frame "name". Text must be UTF encoded (see setText() as reference). If "name" is not given the currently selected Item is used.

insertText

insertText("text", pos, ["name"])

Inserts the text "text" at the position "pos" into the text frame "name". Text must be UTF encoded (see setText() as reference) The first character has an index of 0. Inserting text at position -1 appends it to the frame. If "name" is not given the currently selected item is used.

For performance reason, this function does not update text layout in any way. As a consequence, you may need to call layoutText() or layoutTextChain() at appropriate times after calling this function and before calling functions such as getFrameText() or getTextLines().

May throw IndexError for an insertion out of bounds.

isPDFBookmark

isPDFBookmark(["name"]) -> bool

Returns true if the text frame "name" is a PDF bookmark. If "name" is not given the currently selected item is used.

May raise WrongFrameTypeError if the target frame is not a text frame

layoutText

layoutText(["name"])

Relayout text in the text frame "name". If "name" is not given the currently selected item is used.

layoutTextChain

layoutTextChain(["name"])

Relayout the whole text chain whom the text frame "name" belongs. If "name" is not given the currently selected item is used.

linkTextFrames

linkTextFrames("fromname", "toname")

Link two text frames. The frame named "fromname" is linked to the frame named "toname". The source frame must not already link to another frame. The target frame must not be linked from another frame.

May throw ScribusException if linking rules are violated.

traceText

traceText(["name"])

Convert the text frame "name" to outlines. If "name" is not given the currently selected item is used.

selectFrameText

selectFrameText(start, count, ["name"])

Selects "count" characters of text in the text frame "name" starting from the character "start". Character counting starts at 0. If "count" is zero, any text selection will be cleared. If "count" is -1, the selection will extend to the end of the frame. If "name" is not given the currently selected item is used.

This function only acts on the text visible in the specified frame. If you need to work on the text contained in a text chain, use selectText() instead. As this function depends on text layout being up-to-date, you may need to call layoutText() or layoutTextChain() before calling this function in order to get expected result.

May throw IndexError if the selection is outside the bounds of the text.

selectText

selectText(start, count, ["name"])

Selects "count" characters of text in the story of the text frame "name" starting from the character "start". Character counting starts at 0. If "count" is zero, any text selection will be cleared. If "name" is not given the currently selected item is used.

May throw IndexError if the selection is outside the bounds of the text.

setCellText

setCellText(row, column, text, ["name"])

Sets the text of the cell at "row", "column" in the table "name" to "text". If "name" is not given the currently selected item is used.

May throw ValueError if the cell does not exist.

setColumnGap

setColumnGap(size, ["name"])

Sets the column gap of the text frame "name" to the value "size". If "name" is not given the currently selected item is used.

May throw ValueError if the column gap is out of bounds (must be positive).

setColumns

setColumns(nr, ["name"])

Sets the number of columns of the text frame "name" to the integer "nr". If "name" is not given the currently selected item is used.

May throw ValueError if number of columns is not at least one.

setFirstLineOffset

setFirstLineOffset(offset, ["name"])

Sets the offset of the first line of text inside text frame "name" to the specified offset policy. If "name" is not given the currently selected item is used. "offset" should be one of the FLOP_* constants defined in this module - see dir(scribus).

May throw ValueError for an invalid offset constant.

setFont

setFont("font", ["name"])

Sets the font of the text frame "name" to "font". If there is some text selected only the selected text is changed. If "name" is not given the currently selected item is used.

May throw ValueError if the font cannot be found.

setFontFeatures

setFontFeatures("fontfeature", ["name"])

Sets the font features of the text frame "name" to "fontfeature". If there is some text selected only the selected text is changed. If "name" is not given the currently selected item is used.

May throw ValueError if the font cannot be found.

setFontSize

setFontSize(size, ["name"])

Sets the font size of the text frame "name" to "size". "size" is treated as a value in points. If there is some text selected only the selected text is changed. "size" must be in the range 1 to 512. If "name" is not given the currently selected item is used.

May throw ValueError for a font size that's out of bounds.

setLineSpacing

setLineSpacing(size, ["name"])

Sets the line spacing ("leading") of the text frame "name" to "size". "size" is a value in points. If "name" is not given the currently selected item is used.

May throw ValueError if the line spacing is out of bounds.

setLineSpacingMode

setLineSpacingMode(mode, ["name"])

Sets the line spacing mode of the text frame "name" to "mode". If "name" is not given the currently selected item is used. Mode values are the same as in createParagraphStyle.

May throw ValueError if the mode is out of bounds.

setPDFBookmark

setPDFBookmark("toggle", ["name"])

Sets whether (toggle = 1) the text frame "name" is a bookmark or not. If "name" is not given the currently selected item is used.

May raise WrongFrameTypeError if the target frame is not a text frame

setText

setText("text", ["name"])

Sets the text of the text frame "name" to the text of the string "text". Text must be UTF8 encoded - use e.g. unicode(text, 'iso-8859-2'). See the FAQ for more details. If "name" is not given the currently selected item is used.

setTextAlignment

setTextAlignment(align, ["name"])

Sets the text alignment of the text frame "name" to the specified alignment. If "name" is not given the currently selected item is used. "align" should be one of the ALIGN_ constants defined in this module - see dir(scribus).

May throw ValueError for an invalid alignment constant.

setTextAnnotation

setTextAnnotation(icon,isopen,["name"])

Turns a text fame into a text annotation.

Arguments: "icon" must be 0-8. The values correspond to:( 0 "Note", 1 "Comment", 2 "Key", 3 "Help", 4 "NewParagraph", 5 "Paragraph", 6 "Insert",7 "Cross", 8 "Circle")n"isopen" is True or False. "name" uses the currently selected item if not given.

Returns: None

May raise WrongFrameTypeError if the target frame is not a text frame

setTextColor

setTextColor("color", ["name"])

Sets the text color of the text frame "name" to the color "color". If there is some text selected only the selected text is changed. If "name" is not given the currently selected item is used.

setTextDirection

setTextDirection(direction, ["name"])

Sets the text direction of the text frame "name" to the specified direction. If "name" is not given the currently selected item is used. "direction" should be one of the DIRECTION_ constants defined in this module - see dir(scribus).

May throw ValueError for an invalid direction constant.

setTextDistances

setTextDistances(left, right, top, bottom, ["name"])

Sets the text distances of the text frame "name" to the values "left" "right", "top" and "bottom". If "name" is not given the currently selected item is used.

May throw ValueError if any of the distances are out of bounds (must be positive).

setTextScalingH

setTextScalingH(scale, ["name"])

Sets the horizontal character scaling of the object "name" to "scale" in percent. If "name" is not given the currently selected item is used.

setTextScalingV

setTextScalingV(scale, ["name"])

Sets the vertical character scaling of the object "name" to "scale" in percent. If "name" is not given the currently selected item is used.

setTextShade

setTextShade(shade, ["name"])

Sets the shading of the text color of the object "name" to "shade". If there is some text selected only the selected text is changed. "shade" must be an integer value in the range from 0 (lightest) to 100 (full color intensity). If "name" is not given the currently selected item is used.

setTextStroke

setTextStroke("color", ["name"])

Set "color" of the text stroke. If "name" is not given the currently selected item is used.

setTextVerticalAlignment

setTextVerticalAlignment(align, ["name"])

Sets the vertical alignment of text inside text frame "name" to the specified alignment. If "name" is not given the currently selected item is used. "align" should be one of the ALIGNV constants defined in this module - see dir(scribus).

May throw ValueError for an invalid alignment constant.

textOverflows

textOverflows(["name", nolinks]) -> integer

Returns 1 if there are overflowing characters in text frame "name", 0 if not. If is nolinks set to non zero value it takes only one frame - it doesn't use text frame linking. Without this parameter it search all linking chain.

May raise WrongFrameTypeError if the target frame is not an text frame

traceText

traceText(["name"])

Deprecated, use outlineText() instead.

unlinkTextFrames

unlinkTextFrames("name")

Remove the specified (named) object from the text frame flow/linkage. If the frame was in the middle of a chain, the previous and next frames will be connected, eg 'a->b->c' becomes 'a->c' when you unlinkTextFrames(b)'

May throw ScribusException if linking rules are violated.

Constants

Text frame first line offset mode

  • FLOP_BASELINEGRID
  • FLOP_FONTASCENT
  • FLOP_LINESPACING
  • FLOP_REALGLYPHHEIGHT

Text paragraph alignment

  • ALIGN_BLOCK
  • ALIGN_CENTERED
  • ALIGN_FORCED
  • ALIGN_LEFT
  • ALIGN_RIGHT

Tabs modes

  • TAB_CENTER
  • TAB_COMMA
  • TAB_LEFT
  • TAB_PERIOD
  • TAB_RIGHT

LTR and RTL directions

  • DIRECTION_LTR
  • DIRECTION_RTL

Text frame vertical alignment

  • ALIGNV_BOTTOM
  • ALIGNV_CENTERED
  • ALIGNV_TOP