Phoenix Logo

phoenix_title wx.richtext.RichTextBuffer

This is a kind of paragraph layout box, used to represent the whole buffer.


class_hierarchy Class Hierarchy

Inheritance diagram for class RichTextBuffer:


method_summary Methods Summary

__init__ Default constructor.
AddDrawingHandler Adds a drawing handler to the end.
AddEventHandler Adds an event handler.
AddFieldType Adds a field type.
AddHandler Adds a file handler to the end.
AddParagraph Convenience function to add a paragraph of text.
BatchingUndo Returns True if we are collapsing commands.
BeginAlignment Begins using alignment.
BeginBatchUndo Begin collapsing undo/redo commands.
BeginBold Begins using bold.
BeginCharacterStyle Begins named character style.
BeginFont Begins using this font.
BeginFontSize Begins using point size.
BeginItalic Begins using italic.
BeginLeftIndent Begins using leftIndent for the left indent, and optionally leftSubIndent for the sub-indent.
BeginLineSpacing Begins line spacing using the specified value.
BeginListStyle Begins named list style.
BeginNumberedBullet Begins numbered bullet.
BeginParagraphSpacing Begins paragraph spacing; pass the before-paragraph and after-paragraph spacing in tenths of a millimetre.
BeginParagraphStyle Begins named paragraph style.
BeginRightIndent Begins a right indent, specified in tenths of a millimetre.
BeginStandardBullet Begins applying a standard bullet, using one of the standard bullet names (currently standard/circle or standard/square .
BeginStyle Begin using a style.
BeginSuppressUndo Begin suppressing undo/redo commands.
BeginSymbolBullet Begins applying a symbol bullet, using a character from the current font.
BeginTextColour Begins using this colour.
BeginURL Begins applying wx.TEXT_ATTR_URL to the content.
BeginUnderline Begins using underline.
CanPasteFromClipboard Returns True if we can paste from the clipboard.
CleanUpDrawingHandlers Clean up drawing handlers.
CleanUpFieldTypes Cleans up field types.
CleanUpHandlers Clean up file handlers.
ClearEventHandlers Clear event handlers.
ClearStyleStack Clears the style stack.
Clone Clones the buffer.
Copy Copies the buffer.
CopyToClipboard Copy the range to the clipboard.
DeleteRangeWithUndo Submits a command to delete this range.
EndAlignment Ends alignment.
EndAllStyles End all styles.
EndBatchUndo End collapsing undo/redo commands.
EndBold Ends using bold.
EndCharacterStyle Ends named character style.
EndFont Ends using a font.
EndFontSize Ends using point size.
EndItalic Ends using italic.
EndLeftIndent Ends left indent.
EndLineSpacing Ends line spacing.
EndListStyle Ends named character style.
EndNumberedBullet Ends numbered bullet.
EndParagraphSpacing Ends paragraph spacing.
EndParagraphStyle Ends named character style.
EndRightIndent Ends right indent.
EndStandardBullet Ends standard bullet.
EndStyle End the style.
EndSuppressUndo End suppressing undo/redo commands.
EndSymbolBullet Ends symbol bullet.
EndTextColour Ends using a colour.
EndURL Ends URL.
EndUnderline Ends using underline.
FindDrawingHandler Finds a drawing handler by name.
FindFieldType Finds a field type by name.
FindHandlerByType Finds a handler by type.
FindHandlerByExtension Finds a file handler by extension and type.
FindHandlerByName Finds a file handler by name.
FindHandlerByFilename Finds a handler by filename or, if supplied, type.
GetBatchedCommand Returns the collapsed command.
GetBulletProportion Returns the factor to multiply by character height to get a reasonable bullet size.
GetBulletRightMargin Returns the minimum margin between bullet and paragraph in 10ths of a mm.
GetCommandProcessor Returns the command processor.
GetDimensionScale Returns the scale factor for displaying certain dimensions such as indentation and inter-paragraph spacing.
GetDrawingHandlers Returns the drawing handlers.
GetExtWildcard Gets a wildcard incorporating all visible handlers.
GetFloatingLayoutMode Returns the floating layout mode.
GetFontScale Returns the scale factor for displaying fonts, for example for more comfortable editing.
GetFontTable Returns the table storing fonts, for quick access and font reuse.
GetHandlerFlags Gets the handler flags, controlling loading and saving.
GetHandlers Returns the file handlers.
GetRenderer Returns the renderer object.
GetScale Returns the scale factor for calculating dimensions.
GetStyleSheet Returns the style sheet.
GetStyleStackSize Returns the size of the style stack, for example to check correct nesting.
HitTest Hit-testing: returns a flag indicating hit test details, plus information about position.
Init Initialisation.
InitStandardHandlers Initialise the standard file handlers.
InsertDrawingHandler Inserts a drawing handler at the front.
InsertHandler Inserts a file handler at the front.
InsertImageWithUndo Submits a command to insert the given image.
InsertNewlineWithUndo Submits a command to insert a newline.
InsertObjectWithUndo Submits a command to insert an object.
InsertParagraphsWithUndo Submits a command to insert paragraphs.
InsertTextWithUndo Submits a command to insert the given text.
IsModified Returns True if the buffer was modified.
LoadFile Loads content from a stream or file.
Modify Mark modified.
PasteFromClipboard Paste the clipboard content to the buffer.
PopStyleSheet Pops the style sheet from the top of the style sheet stack.
PushStyleSheet Pushes the style sheet to the top of the style sheet stack.
RemoveDrawingHandler Removes a drawing handler.
RemoveEventHandler Removes an event handler from the buffer’s list of handlers, deleting the object if deleteHandler is True.
RemoveFieldType Removes a field type by name.
RemoveHandler Removes a file handler.
ResetAndClearCommands Clears the buffer, adds an empty paragraph, and clears the command processor.
SaveFile Saves content to a stream or file.
SendEvent Send event to event handlers.
SetBulletProportion Sets the factor to multiply by character height to get a reasonable bullet size.
SetBulletRightMargin Sets the minimum margin between bullet and paragraph in 10ths of a mm.
SetDimensionScale Sets the scale factor for displaying certain dimensions such as indentation and inter-paragraph spacing.
SetFloatingLayoutMode Sets the floating layout mode.
SetFontScale Sets the scale factor for displaying fonts, for example for more comfortable editing.
SetFontTable Sets table storing fonts, for quick access and font reuse.
SetHandlerFlags Sets the handler flags, controlling loading and saving.
SetRenderer Sets renderer as the object to be used to render certain aspects of the content, such as bullets.
SetScale Sets the scale factor for calculating dimensions.
SetStyleSheet Sets style sheet, if any.
SetStyleSheetAndNotify Sets the style sheet and sends a notification of the change.
SubmitAction Submit the action immediately, or delay according to whether collapsing is on.
SuppressingUndo Are we suppressing undo??

api Class API



class wx.richtext.RichTextBuffer(RichTextParagraphLayoutBox)

Possible constructors:

RichTextBuffer()

RichTextBuffer(obj)

This is a kind of paragraph layout box, used to represent the whole buffer.


Methods



__init__(self, *args, **kw)

overload Overloaded Implementations:



__init__ (self)

Default constructor.



__init__ (self, obj)

Copy constructor.

Parameters:obj (wx.richtext.RichTextBuffer) –





static AddDrawingHandler(handler)

Adds a drawing handler to the end.

Parameters:handler (wx.richtext.RichTextDrawingHandler) –


AddEventHandler(self, handler)

Adds an event handler.

A buffer associated with a control has the control as the only event handler, but the application is free to add more if further notification is required. All handlers are notified of an event originating from the buffer, such as the replacement of a style sheet during loading.

The buffer never deletes any of the event handlers, unless RemoveEventHandler is called with True as the second argument.

Parameters:handler (wx.EvtHandler) –
Return type:bool


static AddFieldType(fieldType)

Adds a field type.

Parameters:fieldType (wx.richtext.RichTextFieldType) –


static AddHandler(handler)

Adds a file handler to the end.

Parameters:handler (wx.richtext.RichTextFileHandler) –


AddParagraph(self, text, paraStyle=None)

Convenience function to add a paragraph of text.

Parameters:
Return type:

wx.richtext.RichTextRange



BatchingUndo(self)

Returns True if we are collapsing commands.

Return type:bool


BeginAlignment(self, alignment)

Begins using alignment.

Parameters:alignment (TextAttrAlignment) –
Return type:bool


BeginBatchUndo(self, cmdName)

Begin collapsing undo/redo commands.

Note that this may not work properly if combining commands that delete or insert content, changing ranges for subsequent actions.

cmdName should be the name of the combined command that will appear next to Undo and Redo in the edit menu.

Parameters:cmdName (string) –
Return type:bool


BeginBold(self)

Begins using bold.

Return type:bool


BeginCharacterStyle(self, characterStyle)

Begins named character style.

Parameters:characterStyle (string) –
Return type:bool


BeginFont(self, font)

Begins using this font.

Parameters:font (wx.Font) –
Return type:bool


BeginFontSize(self, pointSize)

Begins using point size.

Parameters:pointSize (int) –
Return type:bool


BeginItalic(self)

Begins using italic.

Return type:bool


BeginLeftIndent(self, leftIndent, leftSubIndent=0)

Begins using leftIndent for the left indent, and optionally leftSubIndent for the sub-indent.

Both are expressed in tenths of a millimetre.

The sub-indent is an offset from the left of the paragraph, and is used for all but the first line in a paragraph. A positive value will cause the first line to appear to the left of the subsequent lines, and a negative value will cause the first line to be indented relative to the subsequent lines.

Parameters:
  • leftIndent (int) –
  • leftSubIndent (int) –
Return type:

bool



BeginLineSpacing(self, lineSpacing)

Begins line spacing using the specified value.

spacing is a multiple, where 10 means single-spacing, 15 means 1.5 spacing, and 20 means float spacing.

The wx.TextAttrLineSpacing enumeration values are defined for convenience.

Parameters:lineSpacing (int) –
Return type:bool


BeginListStyle(self, listStyle, level=1, number=1)

Begins named list style.

Optionally, you can also pass a level and a number.

Parameters:
  • listStyle (string) –
  • level (int) –
  • number (int) –
Return type:

bool



BeginNumberedBullet(self, bulletNumber, leftIndent, leftSubIndent, bulletStyle=TEXT_ATTR_BULLET_STYLE_ARABIC|TEXT_ATTR_BULLET_STYLE_PERIOD)

Begins numbered bullet.

This call will be needed for each item in the list, and the application should take care of incrementing the numbering.

bulletNumber is a number, usually starting with 1. leftIndent and leftSubIndent are values in tenths of a millimetre. bulletStyle is a bitlist of the following values:

wx.richtext.RichTextBuffer uses indentation to render a bulleted item. The left indent is the distance between the margin and the bullet. The content of the paragraph, including the first line, starts at leftMargin + leftSubIndent. So the distance between the left edge of the bullet and the left of the actual paragraph is leftSubIndent.

Parameters:
  • bulletNumber (int) –
  • leftIndent (int) –
  • leftSubIndent (int) –
  • bulletStyle (int) –
Return type:

bool



BeginParagraphSpacing(self, before, after)

Begins paragraph spacing; pass the before-paragraph and after-paragraph spacing in tenths of a millimetre.

Parameters:
  • before (int) –
  • after (int) –
Return type:

bool



BeginParagraphStyle(self, paragraphStyle)

Begins named paragraph style.

Parameters:paragraphStyle (string) –
Return type:bool


BeginRightIndent(self, rightIndent)

Begins a right indent, specified in tenths of a millimetre.

Parameters:rightIndent (int) –
Return type:bool


BeginStandardBullet(self, bulletName, leftIndent, leftSubIndent, bulletStyle=TEXT_ATTR_BULLET_STYLE_STANDARD)

Begins applying a standard bullet, using one of the standard bullet names (currently standard/circle or standard/square .

See BeginNumberedBullet for an explanation of how indentation is used to render the bulleted paragraph.

Parameters:
  • bulletName (string) –
  • leftIndent (int) –
  • leftSubIndent (int) –
  • bulletStyle (int) –
Return type:

bool



BeginStyle(self, style)

Begin using a style.

Parameters:style (wx.richtext.RichTextAttr) –
Return type:bool


BeginSuppressUndo(self)

Begin suppressing undo/redo commands.

The way undo is suppressed may be implemented differently by each command. If not dealt with by a command implementation, then it will be implemented automatically by not storing the command in the undo history when the action is submitted to the command processor.

Return type:bool


BeginSymbolBullet(self, symbol, leftIndent, leftSubIndent, bulletStyle=TEXT_ATTR_BULLET_STYLE_SYMBOL)

Begins applying a symbol bullet, using a character from the current font.

See BeginNumberedBullet for an explanation of how indentation is used to render the bulleted paragraph.

Parameters:
  • symbol (string) –
  • leftIndent (int) –
  • leftSubIndent (int) –
  • bulletStyle (int) –
Return type:

bool



BeginTextColour(self, colour)

Begins using this colour.

Parameters:colour (wx.Colour) –
Return type:bool


BeginURL(self, url, characterStyle="")

Begins applying wx.TEXT_ATTR_URL to the content.

Pass a URL and optionally, a character style to apply, since it is common to mark a URL with a familiar style such as blue text with underlining.

Parameters:
  • url (string) –
  • characterStyle (string) –
Return type:

bool



BeginUnderline(self)

Begins using underline.

Return type:bool


CanPasteFromClipboard(self)

Returns True if we can paste from the clipboard.

Return type:bool


static CleanUpDrawingHandlers()

Clean up drawing handlers.



static CleanUpFieldTypes()

Cleans up field types.



static CleanUpHandlers()

Clean up file handlers.



ClearEventHandlers(self)

Clear event handlers.



ClearStyleStack(self)

Clears the style stack.



Clone(self)

Clones the buffer.

Return type: wx.richtext.RichTextObject


Copy(self, obj)

Copies the buffer.

Parameters:obj (wx.richtext.RichTextBuffer) –


CopyToClipboard(self, range)

Copy the range to the clipboard.

Parameters:range (wx.richtext.RichTextRange) –
Return type:bool


DeleteRangeWithUndo(self, range, ctrl)

Submits a command to delete this range.

Parameters:
Return type:

bool



EndAlignment(self)

Ends alignment.

Return type:bool


EndAllStyles(self)

End all styles.

Return type:bool


EndBatchUndo(self)

End collapsing undo/redo commands.

Return type:bool


EndBold(self)

Ends using bold.

Return type:bool


EndCharacterStyle(self)

Ends named character style.

Return type:bool


EndFont(self)

Ends using a font.

Return type:bool


EndFontSize(self)

Ends using point size.

Return type:bool


EndItalic(self)

Ends using italic.

Return type:bool


EndLeftIndent(self)

Ends left indent.

Return type:bool


EndLineSpacing(self)

Ends line spacing.

Return type:bool


EndListStyle(self)

Ends named character style.

Return type:bool


EndNumberedBullet(self)

Ends numbered bullet.

Return type:bool


EndParagraphSpacing(self)

Ends paragraph spacing.

Return type:bool


EndParagraphStyle(self)

Ends named character style.

Return type:bool


EndRightIndent(self)

Ends right indent.

Return type:bool


EndStandardBullet(self)

Ends standard bullet.

Return type:bool


EndStyle(self)

End the style.

Return type:bool


EndSuppressUndo(self)

End suppressing undo/redo commands.

Return type:bool


EndSymbolBullet(self)

Ends symbol bullet.

Return type:bool


EndTextColour(self)

Ends using a colour.

Return type:bool


EndURL(self)

Ends URL.

Return type:bool


EndUnderline(self)

Ends using underline.

Return type:bool


static FindDrawingHandler(name)

Finds a drawing handler by name.

Parameters:name (string) –
Return type: wx.richtext.RichTextDrawingHandler


static FindFieldType(name)

Finds a field type by name.

Parameters:name (string) –
Return type: wx.richtext.RichTextFieldType


static FindHandlerByType(imageType)

Finds a handler by type.

Parameters:imageType (RichTextFileType) –
Return type: wx.richtext.RichTextFileHandler


static FindHandlerByExtension(extension, imageType)

Finds a file handler by extension and type.

Parameters:
Return type:

wx.richtext.RichTextFileHandler



static FindHandlerByName(name)

Finds a file handler by name.

Parameters:name (string) –
Return type: wx.richtext.RichTextFileHandler


static FindHandlerByFilename(filename, imageType)

Finds a handler by filename or, if supplied, type.

Parameters:
Return type:

wx.richtext.RichTextFileHandler



GetBatchedCommand(self)

Returns the collapsed command.

Return type: wx.richtext.RichTextCommand


static GetBulletProportion()

Returns the factor to multiply by character height to get a reasonable bullet size.

Return type:float


static GetBulletRightMargin()

Returns the minimum margin between bullet and paragraph in 10ths of a mm.

Return type:int


GetCommandProcessor(self)

Returns the command processor.

A text buffer always creates its own command processor when it is initialized.

Return type:CommandProcessor


GetDimensionScale(self)

Returns the scale factor for displaying certain dimensions such as indentation and inter-paragraph spacing.

Return type:float


static GetDrawingHandlers()

Returns the drawing handlers.

Return type:RichTextDrawingHandlerList


static GetExtWildcard(combine=False, save=False, types=None)

Gets a wildcard incorporating all visible handlers.

If types is present, it will be filled with the file type corresponding to each filter. This can be used to determine the type to pass to LoadFile given a selected filter.

Parameters:
  • combine (bool) –
  • save (bool) –
  • types (list of integers) –
Return type:

string



static GetFloatingLayoutMode()

Returns the floating layout mode.

The default is True, where objects are laid out according to their floating status.

Return type:bool


GetFontScale(self)

Returns the scale factor for displaying fonts, for example for more comfortable editing.

Return type:float


GetFontTable(self)

Returns the table storing fonts, for quick access and font reuse.

Return type: wx.richtext.RichTextFontTable


GetHandlerFlags(self)

Gets the handler flags, controlling loading and saving.

Return type:int


static GetHandlers()

Returns the file handlers.

Return type:RichTextFileHandlerList


static GetRenderer()

Returns the renderer object.

Return type: wx.richtext.RichTextRenderer


GetScale(self)

Returns the scale factor for calculating dimensions.

Return type:float


GetStyleSheet(self)

Returns the style sheet.

Return type: wx.richtext.RichTextStyleSheet


GetStyleStackSize(self)

Returns the size of the style stack, for example to check correct nesting.

Return type:int


HitTest(self, dc, context, pt, flags=0)

Hit-testing: returns a flag indicating hit test details, plus information about position.

contextObj is returned to specify what object position is relevant to, since otherwise there’s an ambiguity. @ obj might not be a child of contextObj, since we may be referring to the container itself if we have no hit on a child - for example if we click outside an object.

The function puts the position in textPosition if one is found. pt is in logical units (a zero y position is at the beginning of the buffer).

Parameters:
Return type:

tuple

Returns:

( int, textPosition, obj, contextObj )



Init(self)

Initialisation.



static InitStandardHandlers()

Initialise the standard file handlers.

Currently, only the plain text loading/saving handler is initialised by default.



static InsertDrawingHandler(handler)

Inserts a drawing handler at the front.

Parameters:handler (wx.richtext.RichTextDrawingHandler) –


static InsertHandler(handler)

Inserts a file handler at the front.

Parameters:handler (wx.richtext.RichTextFileHandler) –


InsertImageWithUndo(self, pos, imageBlock, ctrl, flags=0, textAttr=RichTextAttr())

Submits a command to insert the given image.

Parameters:
Return type:

bool



InsertNewlineWithUndo(self, pos, ctrl, flags=0)

Submits a command to insert a newline.

Parameters:
Return type:

bool



InsertObjectWithUndo(self, pos, object, ctrl, flags)

Submits a command to insert an object.

Parameters:
Return type:

wx.richtext.RichTextObject



InsertParagraphsWithUndo(self, pos, paragraphs, ctrl, flags=0)

Submits a command to insert paragraphs.

Parameters:
Return type:

bool



InsertTextWithUndo(self, pos, text, ctrl, flags=0)

Submits a command to insert the given text.

Parameters:
Return type:

bool



IsModified(self)

Returns True if the buffer was modified.

Return type:bool


LoadFile(self, *args, **kw)

Loads content from a stream or file.

Not all handlers will implement file loading.

overload Overloaded Implementations:



LoadFile (self, filename, type=RICHTEXT_TYPE_ANY)

Parameters:
Return type:

bool



LoadFile (self, stream, type=RICHTEXT_TYPE_ANY)

Parameters:
Return type:

bool





Modify(self, modify=True)

Mark modified.

Parameters:modify (bool) –


PasteFromClipboard(self, position)

Paste the clipboard content to the buffer.

Parameters:position (long) –
Return type:bool


PopStyleSheet(self)

Pops the style sheet from the top of the style sheet stack.

Return type: wx.richtext.RichTextStyleSheet


PushStyleSheet(self, styleSheet)

Pushes the style sheet to the top of the style sheet stack.

Parameters:styleSheet (wx.richtext.RichTextStyleSheet) –
Return type:bool


static RemoveDrawingHandler(name)

Removes a drawing handler.

Parameters:name (string) –
Return type:bool


RemoveEventHandler(self, handler, deleteHandler=False)

Removes an event handler from the buffer’s list of handlers, deleting the object if deleteHandler is True.

Parameters:
Return type:

bool



static RemoveFieldType(name)

Removes a field type by name.

Parameters:name (string) –
Return type:bool


static RemoveHandler(name)

Removes a file handler.

Parameters:name (string) –
Return type:bool


ResetAndClearCommands(self)

Clears the buffer, adds an empty paragraph, and clears the command processor.



SaveFile(self, *args, **kw)

Saves content to a stream or file.

Not all handlers will implement file saving.

overload Overloaded Implementations:



SaveFile (self, filename, type=RICHTEXT_TYPE_ANY)

Parameters:
Return type:

bool



SaveFile (self, stream, type=RICHTEXT_TYPE_ANY)

Parameters:
Return type:

bool





SendEvent(self, event, sendToAll=True)

Send event to event handlers.

If sendToAll is True, will send to all event handlers, otherwise will stop at the first successful one.

Parameters:
  • event (wx.Event) –
  • sendToAll (bool) –
Return type:

bool



static SetBulletProportion(prop)

Sets the factor to multiply by character height to get a reasonable bullet size.

Parameters:prop (float) –


static SetBulletRightMargin(margin)

Sets the minimum margin between bullet and paragraph in 10ths of a mm.

Parameters:margin (int) –


SetDimensionScale(self, dimScale)

Sets the scale factor for displaying certain dimensions such as indentation and inter-paragraph spacing.

This can be useful when editing in a small control where you still want legible text, but a minimum of wasted white space.

Parameters:dimScale (float) –


static SetFloatingLayoutMode(mode)

Sets the floating layout mode.

Pass False to speed up editing by not performing floating layout. This setting affects all buffers.

Parameters:mode (bool) –


SetFontScale(self, fontScale)

Sets the scale factor for displaying fonts, for example for more comfortable editing.

Parameters:fontScale (float) –


SetFontTable(self, table)

Sets table storing fonts, for quick access and font reuse.

Parameters:table (wx.richtext.RichTextFontTable) –


SetHandlerFlags(self, flags)

Sets the handler flags, controlling loading and saving.

Parameters:flags (int) –


static SetRenderer(renderer)

Sets renderer as the object to be used to render certain aspects of the content, such as bullets.

You can override default rendering by deriving a new class from wx.richtext.RichTextRenderer or wx.richtext.RichTextStdRenderer, overriding one or more virtual functions, and setting an instance of the class using this function.

Parameters:renderer (wx.richtext.RichTextRenderer) –


SetScale(self, scale)

Sets the scale factor for calculating dimensions.

Parameters:scale (float) –


SetStyleSheet(self, styleSheet)

Sets style sheet, if any.

This will allow the application to use named character and paragraph styles found in the style sheet.

Neither the buffer nor the control owns the style sheet so must be deleted by the application.

Parameters:styleSheet (wx.richtext.RichTextStyleSheet) –


SetStyleSheetAndNotify(self, sheet)

Sets the style sheet and sends a notification of the change.

Parameters:sheet (wx.richtext.RichTextStyleSheet) –
Return type:bool


SubmitAction(self, action)

Submit the action immediately, or delay according to whether collapsing is on.

Parameters:action (wx.richtext.RichTextAction) –
Return type:bool


SuppressingUndo(self)

Are we suppressing undo??

Return type:bool

Properties



BatchedCommand

See GetBatchedCommand



CommandProcessor

See GetCommandProcessor



DimensionScale

See GetDimensionScale and SetDimensionScale



FontScale

See GetFontScale and SetFontScale



FontTable

See GetFontTable and SetFontTable



HandlerFlags

See GetHandlerFlags and SetHandlerFlags



Scale

See GetScale and SetScale



StyleSheet

See GetStyleSheet and SetStyleSheet



StyleStackSize

See GetStyleStackSize