wx.richtext.RichTextCtrl provides a generic, ground-up implementation of a text control capable of showing multiple styles and images.
wx.richtext.RichTextCtrl sends notification events: see wx.richtext.RichTextEvent.
It also sends the standard wx.TextCtrl events wxEVT_TEXT_ENTER
and wxEVT_TEXT
, and wx.TextUrlEvent when URL content is clicked.
For more information, see the RichTextCtrl Overview.
^^
This class supports the following styles:
wx.richtext.RE_CENTRE_CARET
: The control will try to keep the caret line centred vertically while editing. wx.richtext.RE_CENTER_CARET
is a synonym for this style.
wx.richtext.RE_MULTILINE
: The control will be multiline (mandatory).
wx.richtext.RE_READONLY
: The control will not be editable. ^^
Default constructor. |
|
Adds an image to the control’s buffer. |
|
Adds a new paragraph of text to the end of the buffer. |
|
Sets the insertion point to the end of the buffer and writes the text. |
|
Applies the given alignment to the selection or the default style (undoable). |
|
Apples bold to the selection or the default style (undoable). |
|
Applies italic to the selection or the default style (undoable). |
|
Applies the style sheet to the buffer, matching paragraph styles in the sheet against named styles in the buffer. |
|
Applies the style sheet to the buffer, for example if the styles have changed. |
|
Applies one or more TextAttrEffects flags to the selection (undoable). |
|
Applies underline to the selection or the default style (undoable). |
|
Call this function to enable auto-completion of the text typed in a single-line text control using the given choices. |
|
Call this function to enable auto-completion of the text using the file system directories. |
|
Call this function to enable auto-completion of the text typed in a single-line text control using all valid file system paths. |
|
Returns |
|
Begins using alignment. |
|
Starts batching undo history for commands. |
|
Begins using bold. |
|
Begins using the named character style. |
|
Begins using this font. |
|
Begins using the given point size. |
|
Begins using italic. |
|
Begins applying a left indent and subindent in tenths of a millimetre. |
|
Begins applying line spacing. |
|
Begins using a specified list style. |
|
Begins a numbered bullet. |
|
Begins paragraph spacing; pass the before-paragraph and after-paragraph spacing in tenths of a millimetre. |
|
Begins applying the named paragraph style. |
|
Begins a right indent, specified in tenths of a millimetre. |
|
Begins applying a symbol bullet. |
|
Begins applying a style. |
|
Starts suppressing undo history for commands. |
|
Begins applying a symbol bullet, using a character from the current font. |
|
Begins using this colour. |
|
Begins applying |
|
Begins using underlining. |
|
Returns |
|
Returns |
|
Can we delete this range? Sends an event to the control. |
|
Returns |
|
Returns |
|
Can we insert content at this position? Sends an event to the control. |
|
Returns |
|
Returns |
|
Returns |
|
Sets the new text control value. |
|
Clears the buffer content, leaving a single empty paragraph. |
|
Clears the cache of available font names. |
|
Clears the list style from the given range, clearing list-related attributes and applying any named paragraph style associated with each paragraph. |
|
Sends the event to the control. |
|
Copies the selected content (if any) to the clipboard. |
|
Creates the underlying window. |
|
Copies the selected content (if any) to the clipboard and deletes the selection. |
|
Deletes the content within the given range. |
|
Deletes content if there is a selection, e.g. |
|
Deletes the content in the selection, if any. |
|
Sets the buffer’s modified status to |
|
Currently this simply returns wx.Size. |
|
Implements layout. |
|
Helper function for |
|
Helper function for |
|
Returns |
|
Edits the object’s properties via a GUI. |
|
Enable or disable delayed image loading. |
|
Enable or disable images. |
|
Enable or disable the vertical scrollbar. |
|
Pass |
|
Ends alignment. |
|
Ends application of all styles in the current style stack. |
|
Ends batching undo command history. |
|
Ends using bold. |
|
Ends application of a named character style. |
|
Ends using a font. |
|
Ends using a point size. |
|
Ends using italic. |
|
Ends left indent. |
|
Ends line spacing. |
|
Ends using a specified list style. |
|
Ends application of a numbered bullet. |
|
Ends paragraph spacing. |
|
Ends application of a named paragraph style. |
|
Ends right indent. |
|
Begins applying a standard bullet. |
|
Ends the current style. |
|
Ends suppressing undo command history. |
|
Ends applying a symbol bullet. |
|
Ends applying a text colour. |
|
Ends applying a URL. |
|
End applying underlining. |
|
Extends a table selection in the given direction. |
|
Helper function for extending the selection, returning |
|
Find the caret position for the combination of hit-test flags and character position. |
|
Finds the container at the given point, which is assumed to be in client coordinates. |
|
Helper function for finding the caret position for the next word. |
|
Given a character position at which there is a list style, find the range encompassing the same list style by looking backwards and forwards. |
|
Convert all text entered into the control to upper case. |
|
The adjusted caret position is the character position adjusted to take into account whether we’re at the start of a paragraph, in which case style information should be taken from the next position, not current one. |
|
Font names take a long time to retrieve, so cache them (on demand). |
|
Gets the basic (overall) style. |
|
Returns the buffer associated with the control. |
|
Returns |
|
Returns the current caret position. |
|
Returns the caret position since the default formatting was changed. |
|
Returns the caret height and position for the given character position. |
|
Gets the command processor associated with the control’s buffer. |
|
Returns the current context menu. |
|
Returns an object that stores information about context menu property item(s), in order to communicate between the context menu event handler and the code that responds to it. |
|
Returns the current default style, which can be used to change how subsequently inserted text is displayed. |
|
Returns |
|
Gets the flag indicating that delayed image processing is required. |
|
Returns the last time delayed image processing was performed. |
|
Gets the size of the buffer beyond which layout is delayed during resizing. |
|
Returns the scale factor for displaying certain dimensions such as indentation and inter-paragraph spacing. |
|
Get the possible Drag’n’Drop start point. |
|
Get the possible Drag’n’Drop start time. |
|
Returns |
|
Gets the current filename associated with the control. |
|
Returns the first visible point in the window. |
|
Returns the first visible position in the current view. |
|
Returns the wx.richtext.RichTextObject object that currently has the editing focus. |
|
Returns the scale factor for displaying fonts, for example for more comfortable editing. |
|
Returns flags that change the behaviour of loading or saving. |
|
Returns the current hint string. |
|
Returns |
|
Returns the current insertion point. |
|
Returns the selection range in character positions. |
|
Returns the last position in the buffer. |
|
Returns the length of the specified line in characters. |
|
Returns the text for the given line. |
|
Transforms physical window position to logical (unscrolled) position. |
|
Returns the margins used by the control. |
|
Returns the number of lines in the buffer. |
|
Transforms logical (unscrolled) position to physical window position. |
|
Are we trying to start Drag’n’Drop? |
|
Gets the object’s properties menu label. |
|
Gets the text for the given range. |
|
Returns an overall scale factor for displaying and editing the content. |
|
Returns a scaled point. |
|
Returns a scaled rectangle. |
|
Returns a scaled size. |
|
Returns the range of the current selection. |
|
Returns an anchor so we know how to extend the selection. |
|
Returns the anchor object if selecting multiple containers. |
|
Returns the selection range in character positions. |
|
Returns the text within the current selection range, if any. |
|
Gets the attributes at the given position. |
|
Gets the attributes common to the specified range. |
|
Returns the style sheet associated with the control, if any. |
|
Returns the text (normal) cursor. |
|
Returns the cursor to be used over URLs. |
|
Gets the attributes at the given position. |
|
Returns an unscaled point. |
|
Returns an unscaled rectangle. |
|
Returns an unscaled size. |
|
Returns the content of the entire control as a string. |
|
Returns |
|
Returns |
|
Internal helper function returning the line for the visible caret position. |
|
Test if this whole range has character attributes of the specified kind. |
|
Test if this whole range has paragraph attributes of the specified kind. |
|
Returns |
|
Returns |
|
Finds the character at the given position in pixels. |
|
Finds the character at the given position in pixels. |
|
Initialises the members of the control. |
|
Invalidates the whole buffer to trigger painting later. |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Helper function implementing keyboard navigation. |
|
Lays out the buffer, which must be done before certain operations, such as setting the caret position. |
|
Inserts a line break at the current insertion point. |
|
Loads content into the control’s buffer using the given type. |
|
Marks the buffer as modified. |
|
Move the caret to the given character position. |
|
Move the caret one visual step forward: this may mean setting a flag and keeping the same position if we’re going from the end of one line to the start of the next, which may be the exact same caret position. |
|
Move the caret one visual step forward: this may mean setting a flag and keeping the same position if we’re going from the end of one line to the start of the next, which may be the exact same caret position. |
|
Moves the caret down. |
|
Moves to the end of the buffer. |
|
Moves to the start of the buffer. |
|
Moves left. |
|
Moves right. |
|
Moves to the end of the line. |
|
Moves to the start of the line. |
|
Moves to the end of the paragraph. |
|
Moves to the start of the paragraph. |
|
Moves to the start of the paragraph. |
|
Inserts a new paragraph at the current insertion point. |
|
Numbers the paragraphs in the given range. |
|
Standard handler for the |
|
Shows a standard context menu with undo, redo, cut, copy, paste, clear, and select all commands. |
|
Standard handler for the |
|
Standard handler for the |
|
Loads the first dropped file. |
|
Standard handler for the |
|
Standard handler for property commands. |
|
Standard handler for the |
|
Standard handler for the |
|
Respond to timer events. |
|
Standard handler for the |
|
Standard update handler for the |
|
Standard update handler for the |
|
Standard update handler for the |
|
Standard update handler for the |
|
Standard update handler for property commands. |
|
Standard update handler for the |
|
Standard update handler for the |
|
Standard update handler for the |
|
Moves one or more pages down. |
|
Moves one or more pages up. |
|
Other user defined painting after everything else (i.e. all text) is painted. |
|
Paints the background. |
|
Pastes content from the clipboard to the buffer. |
|
Pops the style sheet from top of stack. |
|
Internal function to position the visible caret according to the current caret position. |
|
Converts a text position to zero-based column and line numbers. |
|
Prepares the content just before insertion (or after buffer reset). |
|
Prepares the context menu, optionally adding appropriate property-editing commands. |
|
Processes the back key. |
|
Do delayed image loading and garbage-collect other images. |
|
Processes mouse movement in order to change the cursor. |
|
Promotes or demotes the paragraphs in the given range. |
|
Push the style sheet to top of stack. |
|
Redoes the current command. |
|
Refreshes the area affected by a selection change. |
|
Removes the content in the specified range. |
|
Replaces the content in the specified range with the string specified by value. |
|
Request delayed image processing. |
|
Saves the buffer content using the given type. |
|
Scrolls position into view. |
|
Selects all the text in the buffer. |
|
Cancels any selection. |
|
Selects the word at the given character position. |
|
Sets |
|
Sets the basic (overall) style. |
|
Sets a flag to remember that we are showing the caret position at the start of a line instead of at the end of the previous one. |
|
Sets the caret position. |
|
Sets up the caret for the given position and container, after a mouse click. |
|
Set the caret position for the default style that the user is selecting. |
|
Sets the current context menu. |
|
Sets the current default style, which can be used to change how subsequently inserted text is displayed. |
|
Sets the default style to the style under the cursor. |
|
Sets the flag indicating that delayed image processing is required. |
|
Sets the last time delayed image processing was performed. |
|
Sets the size of the buffer beyond which layout is delayed during resizing. |
|
Sets the scale factor for displaying certain dimensions such as indentation and inter-paragraph spacing. |
|
Set the possible Drag’n’Drop start point. |
|
Set the possible Drag’n’Drop start time. |
|
Sets a flag to remember if we are extending a selection. |
|
Makes the control editable, or not. |
|
Sets the current filename. |
|
Sets the wx.richtext.RichTextObject object that currently has the editing focus. |
|
Sets the font, and also the basic and default attributes (see |
|
Sets the scale factor for displaying fonts, for example for more comfortable editing. |
|
Sets flags that change the behaviour of loading or saving. |
|
Sets a hint shown in an empty unfocused text control. |
|
Sets the insertion point and causes the current editing style to be taken from the new position (unlike |
|
Sets the insertion point to the end of the text control. |
|
Sets the selection range in character positions. |
|
Sets the list attributes for the given range, passing flags to determine how the attributes are set. |
|
Attempts to set the control margins. |
|
Sets the maximum number of characters that may be entered in a single line text control. |
|
Set if we’re trying to start Drag’n’Drop. |
|
Sets the properties for the given range, passing flags to determine how the attributes are set. |
|
Sets an overall scale factor for displaying and editing the content. |
|
Sets the selection to the given range. |
|
Sets an anchor so we know how to extend the selection. |
|
Sets the anchor object if selecting multiple containers. |
|
Sets the selection to the given range. |
|
Sets the attributes for the given range. |
|
Sets the attributes for the given range, passing flags to determine how the attributes are set. |
|
Sets the style sheet associated with the control. |
|
Sets the text (normal) cursor. |
|
Sets the cursor to be used over URLs. |
|
Replaces existing content with the given text. |
|
A helper function setting up scrollbars, for example after a resize. |
|
Return |
|
Shows the given context menu, optionally adding appropriate property-editing commands for the current position in the object hierarchy. |
|
Scrolls the buffer so that the given position is in view. |
|
Starts selecting table cells. |
|
Setter for m_focusObject. |
|
Returns |
|
Undoes the command at the top of the command history, if there is one. |
|
Moves a number of words to the left. |
|
Move a number of words to the right. |
|
Writes a field at the current insertion point. |
|
Write a bitmap or image at the current insertion point. |
|
Write a table at the current insertion point, returning the table. |
|
Writes text at the current position. |
|
Write a text box at the current insertion point, returning the text box. |
|
Translates from column and line number to position. |
wx.richtext.
RichTextCtrl
(Control)¶Possible constructors:
RichTextCtrl()
RichTextCtrl(parent, id=-1, value="", pos=DefaultPosition,
size=DefaultSize, style=RE_MULTILINE, validator=DefaultValidator,
name=TextCtrlNameStr)
RichTextCtrl provides a generic, ground-up implementation of a text control capable of showing multiple styles and images.
__init__
(self, *args, **kw)¶__init__ (self)
Default constructor.
__init__ (self, parent, id=-1, value=””, pos=DefaultPosition, size=DefaultSize, style=RE_MULTILINE, validator=DefaultValidator, name=TextCtrlNameStr)
Constructor, creating and showing a rich text control.
parent (wx.Window) – Parent window. Must not be None
.
id (wx.WindowID) – Window identifier. The value ID_ANY
indicates a default value.
value (string) – Default string.
pos (wx.Point) – Window position.
size (wx.Size) – Window size.
style (long) – Window style.
validator (wx.Validator) – Window validator.
name (string) – Window name.
AddImage
(self, image)¶Adds an image to the control’s buffer.
image (wx.Image) –
AddParagraph
(self, text)¶Adds a new paragraph of text to the end of the buffer.
text (string) –
AppendText
(self, text)¶Sets the insertion point to the end of the buffer and writes the text.
text (string) –
ApplyAlignmentToSelection
(self, alignment)¶Applies the given alignment to the selection or the default style (undoable).
For alignment values, see wx.TextAttr.
alignment (TextAttrAlignment) –
bool
ApplyBoldToSelection
(self)¶Apples bold to the selection or the default style (undoable).
bool
ApplyItalicToSelection
(self)¶Applies italic to the selection or the default style (undoable).
bool
ApplyStyle
(self, styleDef)¶Applies the style sheet to the buffer, matching paragraph styles in the sheet against named styles in the buffer.
This might be useful if the styles have changed. If sheet is None
, the sheet set with SetStyleSheet
is used. Currently this applies paragraph styles only.
styleDef (wx.richtext.RichTextStyleDefinition) –
bool
ApplyStyleSheet
(self, styleSheet=None)¶Applies the style sheet to the buffer, for example if the styles have changed.
styleSheet (wx.richtext.RichTextStyleSheet) –
bool
ApplyTextEffectToSelection
(self, flags)¶Applies one or more TextAttrEffects flags to the selection (undoable).
If there is no selection, it is applied to the default style.
flags (int) –
bool
ApplyUnderlineToSelection
(self)¶Applies underline to the selection or the default style (undoable).
bool
AutoComplete
(self, *args, **kw)¶AutoComplete (self, choices)
Call this function to enable auto-completion of the text typed in a single-line text control using the given choices.
choices (list of strings) –
bool
True
if the auto-completion was enabled or False
if the operation failed, typically because auto-completion is not supported by the current platform.
New in version 2.9.0.
See also
AutoComplete (self, completer)
Enable auto-completion using the provided completer object.
This method should be used instead of AutoComplete
overload taking the array of possible completions if the total number of strings is too big as it allows returning the completions dynamically, depending on the text already entered by user and so is more efficient.
The specified completer object will be used to retrieve the list of possible completions for the already entered text and will be deleted by wx.TextEntry itself when it’s not needed any longer.
Notice that you need to include /textcompleter.h in order to define your class inheriting from wx.TextCompleter.
completer (wx.TextCompleter) – The object to be used for generating completions if not None
. If it is None
, auto-completion is disabled. The wx.TextEntry object takes ownership of this pointer and will delete it in any case (i.e. even if this method returns False
).
bool
True
if the auto-completion was enabled or False
if the operation failed, typically because auto-completion is not supported by the current platform.
New in version 2.9.2.
AutoCompleteDirectories
(self)¶Call this function to enable auto-completion of the text using the file system directories.
Unlike AutoCompleteFileNames
which completes both file names and directories, this function only completes the directory names.
Notice that currently this function is only implemented in wxMSW port and does nothing under the other platforms.
bool
True
if the auto-completion was enabled or False
if the operation failed, typically because auto-completion is not supported by the current platform.
New in version 2.9.3.
See also
AutoCompleteFileNames
(self)¶Call this function to enable auto-completion of the text typed in a single-line text control using all valid file system paths.
Notice that currently this function is only implemented in wxMSW port and does nothing under the other platforms.
bool
True
if the auto-completion was enabled or False
if the operation failed, typically because auto-completion is not supported by the current platform.
New in version 2.9.0.
See also
BatchingUndo
(self)¶Returns True
if undo commands are being batched.
bool
BeginAlignment
(self, alignment)¶Begins using alignment.
For alignment values, see wx.TextAttr.
alignment (TextAttrAlignment) –
bool
BeginBatchUndo
(self, cmdName)¶Starts batching undo history for commands.
cmdName (string) –
bool
BeginBold
(self)¶Begins using bold.
bool
BeginCharacterStyle
(self, characterStyle)¶Begins using the named character style.
characterStyle (string) –
bool
BeginFontSize
(self, pointSize)¶Begins using the given point size.
pointSize (int) –
bool
BeginItalic
(self)¶Begins using italic.
bool
BeginLeftIndent
(self, leftIndent, leftSubIndent=0)¶Begins applying a left indent and subindent in tenths of a millimetre.
The subindent is an offset from the left edge 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 to the right of the subsequent lines.
wx.richtext.RichTextBuffer uses indentation to render a bulleted item. The content of the paragraph, including the first line, starts at the leftIndent plus the leftSubIndent.
leftIndent (int) – The distance between the margin and the bullet.
leftSubIndent (int) – The distance between the left edge of the bullet and the left edge of the actual paragraph.
bool
BeginLineSpacing
(self, lineSpacing)¶Begins applying line spacing.
spacing is a multiple, where 10 means single-spacing, 15 means 1.5 spacing, and 20 means float spacing.
The wx.TextAttrLineSpacing constants are defined for convenience.
lineSpacing (int) –
bool
BeginListStyle
(self, listStyle, level=1, number=1)¶Begins using a specified list style.
Optionally, you can also pass a level and a number.
listStyle (string) –
level (int) –
number (int) –
bool
BeginNumberedBullet
(self, bulletNumber, leftIndent, leftSubIndent, bulletStyle=TEXT_ATTR_BULLET_STYLE_ARABIC|TEXT_ATTR_BULLET_STYLE_PERIOD)¶Begins a 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 wx.TextAttrBulletStyle 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.
bulletNumber (int) –
leftIndent (int) –
leftSubIndent (int) –
bulletStyle (int) –
bool
BeginParagraphSpacing
(self, before, after)¶Begins paragraph spacing; pass the before-paragraph and after-paragraph spacing in tenths of a millimetre.
before (int) –
after (int) –
bool
BeginParagraphStyle
(self, paragraphStyle)¶Begins applying the named paragraph style.
paragraphStyle (string) –
bool
BeginRightIndent
(self, rightIndent)¶Begins a right indent, specified in tenths of a millimetre.
rightIndent (int) –
bool
BeginStandardBullet
(self, bulletName, leftIndent, leftSubIndent, bulletStyle=TEXT_ATTR_BULLET_STYLE_STANDARD)¶Begins applying a symbol bullet.
bulletName (string) –
leftIndent (int) –
leftSubIndent (int) –
bulletStyle (int) –
bool
BeginStyle
(self, style)¶Begins applying a style.
style (wx.richtext.RichTextAttr) –
bool
BeginSuppressUndo
(self)¶Starts suppressing undo history for commands.
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.
symbol (string) –
leftIndent (int) –
leftSubIndent (int) –
bulletStyle (int) –
bool
BeginTextColour
(self, colour)¶Begins using this colour.
colour (wx.Colour) –
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.
url (string) –
characterStyle (string) –
bool
BeginUnderline
(self)¶Begins using underlining.
bool
CanCopy
(self)¶Returns True
if selected content can be copied to the clipboard.
bool
CanCut
(self)¶Returns True
if selected content can be copied to the clipboard and deleted.
bool
CanDeleteRange
(self, container, range)¶Can we delete this range? Sends an event to the control.
container (wx.richtext.RichTextParagraphLayoutBox) –
range (wx.richtext.RichTextRange) –
bool
CanDeleteSelection
(self)¶Returns True
if selected content can be deleted.
bool
CanEditProperties
(self, obj)¶Returns True
if we can edit the object’s properties via a GUI.
obj (wx.richtext.RichTextObject) –
bool
CanInsertContent
(self, container, pos)¶Can we insert content at this position? Sends an event to the control.
container (wx.richtext.RichTextParagraphLayoutBox) –
pos (long) –
bool
CanPaste
(self)¶Returns True
if the clipboard content can be pasted to the buffer.
bool
CanRedo
(self)¶Returns True
if there is a command in the command history that can be redone.
bool
CanUndo
(self)¶Returns True
if there is a command in the command history that can be undone.
bool
ChangeValue
(self, value)¶Sets the new text control value.
It also marks the control as not-modified which means that IsModified() would return False
immediately after the call to ChangeValue
.
The insertion point is set to the start of the control (i.e. position 0) by this function.
This functions does not generate the wxEVT_TEXT
event but otherwise is identical to SetValue
.
See User Generated Events vs Programmatically Generated Events for more information.
value (string) – The new value to set. It may contain newline characters if the text control is multi-line.
New in version 2.7.1.
Clear
(self)¶Clears the buffer content, leaving a single empty paragraph.
Cannot be undone.
ClearAvailableFontNames
()¶Clears the cache of available font names.
ClearListStyle
(self, range, flags=RICHTEXT_SETSTYLE_WITH_UNDO)¶Clears the list style from the given range, clearing list-related attributes and applying any named paragraph style associated with each paragraph.
flags is a bit list of the following:
wx.richtext.RICHTEXT_SETSTYLE_WITH_UNDO
: specifies that this command will be undoable.
range (wx.richtext.RichTextRange) –
flags (int) –
bool
See also
Command
(self, event)¶Sends the event to the control.
event (wx.CommandEvent) –
Copy
(self)¶Copies the selected content (if any) to the clipboard.
Create
(self, parent, id=-1, value="", pos=DefaultPosition, size=DefaultSize, style=RE_MULTILINE, validator=DefaultValidator, name=TextCtrlNameStr)¶Creates the underlying window.
parent (wx.Window) –
id (wx.WindowID) –
value (string) –
pos (wx.Point) –
size (wx.Size) –
style (long) –
validator (wx.Validator) –
name (string) –
bool
Cut
(self)¶Copies the selected content (if any) to the clipboard and deletes the selection.
This is undoable.
Delete
(self, range)¶Deletes the content within the given range.
range (wx.richtext.RichTextRange) –
bool
DeleteSelectedContent
(self, newPos=None)¶Deletes content if there is a selection, e.g.
when pressing a key. Returns the new caret position in newPos, or leaves it if there was no action. This is undoable.
DeleteSelection
(self)¶Deletes the content in the selection, if any.
This is undoable.
DiscardEdits
(self)¶Sets the buffer’s modified status to False
, and clears the buffer’s command history.
DoGetValue
(self)¶string
DoLayoutBuffer
(self, buffer, dc, context, rect, parentRect, flags)¶Implements layout.
An application may override this to perform operations before or after layout.
buffer (wx.richtext.RichTextBuffer) –
dc (wx.DC) –
context (wx.richtext.RichTextDrawingContext) –
rect (wx.Rect) –
parentRect (wx.Rect) –
flags (int) –
DoLoadFile
(self, file, fileType)¶Helper function for LoadFile
.
Loads content into the control’s buffer using the given type.
If the specified type is wx.richtext.RICHTEXT_TYPE_ANY
, the type is deduced from the filename extension.
This function looks for a suitable wx.richtext.RichTextFileHandler object.
file (string) –
fileType (int) –
bool
DoSaveFile
(self, file="", fileType=RICHTEXT_TYPE_ANY)¶Helper function for SaveFile
.
Saves the buffer content using the given type.
If the specified type is wx.richtext.RICHTEXT_TYPE_ANY
, the type is deduced from the filename extension.
This function looks for a suitable wx.richtext.RichTextFileHandler object.
file (string) –
fileType (int) –
bool
DoThaw
(self)¶DoWriteText
(self, value, flags=0)¶value (string) –
flags (int) –
DoesSelectionHaveTextEffectFlag
(self, flag)¶Returns True
if all of the selection, or the content at the current caret position, has the supplied TextAttrEffects flag(s).
flag (int) –
bool
EditProperties
(self, obj, parent)¶Edits the object’s properties via a GUI.
obj (wx.richtext.RichTextObject) –
parent (wx.Window) –
bool
EnableDelayedImageLoading
(self, b)¶Enable or disable delayed image loading.
b (bool) –
EnableImages
(self, b)¶Enable or disable images.
b (bool) –
EnableVerticalScrollbar
(self, enable)¶Enable or disable the vertical scrollbar.
enable (bool) –
EnableVirtualAttributes
(self, b)¶Pass True
to let the control use virtual attributes.
The default is False
.
b (bool) –
EndAlignment
(self)¶Ends alignment.
bool
EndAllStyles
(self)¶Ends application of all styles in the current style stack.
bool
EndBatchUndo
(self)¶Ends batching undo command history.
bool
EndBold
(self)¶Ends using bold.
bool
EndCharacterStyle
(self)¶Ends application of a named character style.
bool
EndFont
(self)¶Ends using a font.
bool
EndFontSize
(self)¶Ends using a point size.
bool
EndItalic
(self)¶Ends using italic.
bool
EndLeftIndent
(self)¶Ends left indent.
bool
EndLineSpacing
(self)¶Ends line spacing.
bool
EndListStyle
(self)¶Ends using a specified list style.
bool
EndNumberedBullet
(self)¶Ends application of a numbered bullet.
bool
EndParagraphSpacing
(self)¶Ends paragraph spacing.
bool
EndParagraphStyle
(self)¶Ends application of a named paragraph style.
bool
EndRightIndent
(self)¶Ends right indent.
bool
EndStandardBullet
(self)¶Begins applying a standard bullet.
bool
EndStyle
(self)¶Ends the current style.
bool
EndSuppressUndo
(self)¶Ends suppressing undo command history.
bool
EndSymbolBullet
(self)¶Ends applying a symbol bullet.
bool
EndTextColour
(self)¶Ends applying a text colour.
bool
EndURL
(self)¶Ends applying a URL.
bool
EndUnderline
(self)¶End applying underlining.
bool
ExtendCellSelection
(self, table, noRowSteps, noColSteps)¶Extends a table selection in the given direction.
table (wx.richtext.RichTextTable) –
noRowSteps (int) –
noColSteps (int) –
bool
ExtendSelection
(self, oldPosition, newPosition, flags)¶Helper function for extending the selection, returning True
if the selection was changed.
Selections are in caret positions.
oldPosition (long) –
newPosition (long) –
flags (int) –
bool
FindCaretPositionForCharacterPosition
(self, position, hitTestFlags, container, caretLineStart)¶Find the caret position for the combination of hit-test flags and character position.
Returns the caret position and also an indication of where to place the caret (caretLineStart) since this is ambiguous (same position used for end of line and start of next).
position (long) –
hitTestFlags (int) –
container (wx.richtext.RichTextParagraphLayoutBox) –
caretLineStart (bool) –
long
FindContainerAtPoint
(self, pt, position, hit, hitObj, flags=0)¶Finds the container at the given point, which is assumed to be in client coordinates.
pt (wx.Point) –
position (long) –
hit (int) –
hitObj (wx.richtext.RichTextObject) –
flags (int) –
FindNextWordPosition
(self, direction=1)¶Helper function for finding the caret position for the next word.
Direction is 1 (forward) or -1 (backwards).
direction (int) –
long
FindRangeForList
(self, pos, isNumberedList)¶Given a character position at which there is a list style, find the range encompassing the same list style by looking backwards and forwards.
pos (long) –
isNumberedList (bool) –
ForceDelayedLayout
(self)¶ForceUpper
(self)¶Convert all text entered into the control to upper case.
Call this method to ensure that all text entered into the control is converted on the fly to upper case. If the control is not empty, its existing contents is also converted to upper case.
New in version 4.1/wxWidgets-3.1.0.
GetAdjustedCaretPosition
(self, caretPos)¶The adjusted caret position is the character position adjusted to take into account whether we’re at the start of a paragraph, in which case style information should be taken from the next position, not current one.
caretPos (long) –
long
GetAvailableFontNames
()¶Font names take a long time to retrieve, so cache them (on demand).
list of strings
GetBasicStyle
(self)¶Gets the basic (overall) style.
This is the style of the whole buffer before further styles are applied, unlike the default style, which only affects the style currently being applied (for example, setting the default style to bold will cause subsequently inserted text to be bold).
GetBuffer
(self)¶Returns the buffer associated with the control.
GetCaretAtLineStart
(self)¶Returns True
if we are showing the caret position at the start of a line instead of at the end of the previous one.
bool
GetCaretPosition
(self)¶Returns the current caret position.
long
GetCaretPositionForDefaultStyle
(self)¶Returns the caret position since the default formatting was changed.
As soon as this position changes, we no longer reflect the default style in the UI. A value of -2 means that we should only reflect the style of the content under the caret.
long
GetCaretPositionForIndex
(self, position, rect, container=None)¶Returns the caret height and position for the given character position.
If container is null, the current focus object will be used.
GetClassDefaultAttributes
(variant=WINDOW_VARIANT_NORMAL)¶variant (WindowVariant) –
VisualAttributes
GetCommandProcessor
(self)¶Gets the command processor associated with the control’s buffer.
GetContextMenu
(self)¶Returns the current context menu.
Menu
GetContextMenuPropertiesInfo
(self)¶Returns an object that stores information about context menu property item(s), in order to communicate between the context menu event handler and the code that responds to it.
The wx.richtext.RichTextContextMenuPropertiesInfo stores one item for each object that could respond to a property-editing event. If objects are nested, several might be editable.
GetDefaultStyleEx
(self)¶Returns the current default style, which can be used to change how subsequently inserted text is displayed.
GetDelayedImageLoading
(self)¶Returns True
if delayed image loading is enabled.
bool
GetDelayedImageProcessingRequired
(self)¶Gets the flag indicating that delayed image processing is required.
bool
GetDelayedImageProcessingTime
(self)¶Returns the last time delayed image processing was performed.
long
GetDelayedLayoutThreshold
(self)¶Gets the size of the buffer beyond which layout is delayed during resizing.
This optimizes sizing for large buffers. The default is 20000.
long
GetDimensionScale
(self)¶Returns the scale factor for displaying certain dimensions such as indentation and inter-paragraph spacing.
float
GetDragStartPoint
(self)¶Get the possible Drag’n’Drop start point.
Point
GetDragStartTime
(self)¶Get the possible Drag’n’Drop start time.
DateTime
GetDragging
(self)¶Returns True
if we are extending a selection.
bool
GetFilename
(self)¶Gets the current filename associated with the control.
string
GetFirstVisiblePoint
(self)¶Returns the first visible point in the window.
Point
GetFirstVisiblePosition
(self)¶Returns the first visible position in the current view.
long
GetFocusObject
(self)¶Returns the wx.richtext.RichTextObject object that currently has the editing focus.
If there are no composite objects, this will be the top-level buffer.
GetFontScale
(self)¶Returns the scale factor for displaying fonts, for example for more comfortable editing.
float
GetFullLayoutRequired
(self)¶bool
GetFullLayoutSavedPosition
(self)¶long
GetFullLayoutTime
(self)¶long
GetHandlerFlags
(self)¶Returns flags that change the behaviour of loading or saving.
See the documentation for each handler class to see what flags are relevant for each handler.
int
GetHint
(self)¶Returns the current hint string.
See SetHint
for more information about hints.
string
New in version 2.9.0.
GetImagesEnabled
(self)¶Returns True
if images are enabled.
bool
GetInsertionPoint
(self)¶Returns the current insertion point.
long
GetInternalSelectionRange
(self)¶Returns the selection range in character positions.
-2, -2 means no selection -1, -1 means select everything. The range is in internal format, i.e. a single character selection is denoted by (n, n)
GetLastPosition
(self)¶Returns the last position in the buffer.
wx.TextPos
GetLineLength
(self, lineNo)¶Returns the length of the specified line in characters.
lineNo (long) –
int
GetLineText
(self, lineNo)¶Returns the text for the given line.
lineNo (long) –
string
GetLogicalPoint
(self, ptPhysical)¶Transforms physical window position to logical (unscrolled) position.
ptPhysical (wx.Point) –
Point
GetMargins
(self)¶Returns the margins used by the control.
The x
field of the returned point is the horizontal margin and the y
field is the vertical one.
New in version 2.9.1.
Note
If given margin cannot be accurately determined, its value will be set to -1. On some platforms you cannot obtain valid margin values until you have called SetMargins
.
See also
GetNumberOfLines
(self)¶Returns the number of lines in the buffer.
int
GetPhysicalPoint
(self, ptLogical)¶Transforms logical (unscrolled) position to physical window position.
ptLogical (wx.Point) –
Point
GetPreDrag
(self)¶Are we trying to start Drag’n’Drop?
bool
GetPropertiesMenuLabel
(self, obj)¶Gets the object’s properties menu label.
obj (wx.richtext.RichTextObject) –
string
GetRange
(self, from_, to_)¶Gets the text for the given range.
The end point of range is specified as the last character position of the span of text, plus one.
from_ (long) –
to_ (long) –
string
GetScale
(self)¶Returns an overall scale factor for displaying and editing the content.
float
GetScaledRect
(self, rect)¶Returns a scaled rectangle.
rect (wx.Rect) –
Rect
GetSelection
(self)¶Returns the range of the current selection.
The end point of range is specified as the last character position of the span of text, plus one. If the return values from and to are the same, there is no selection.
GetSelectionAnchor
(self)¶Returns an anchor so we know how to extend the selection.
It’s a caret position since it’s between two characters.
long
GetSelectionAnchorObject
(self)¶Returns the anchor object if selecting multiple containers.
GetSelectionRange
(self)¶Returns the selection range in character positions.
-1, -1 means no selection.
The range is in API convention, i.e. a single character selection is denoted by (n, n+1)
GetStringSelection
(self)¶Returns the text within the current selection range, if any.
string
GetStyle
(self, *args, **kw)¶Gets the attributes at the given position.
This function gets the combined style - that is, the style you see on the screen as a result of combining base style, paragraph style and character style attributes.
To get the character or paragraph style alone, use GetUncombinedStyle
.
GetStyleForRange
(self, *args, **kw)¶Gets the attributes common to the specified range.
Attributes that differ in value within the range will not be included in style flags.
GetStyleSheet
(self)¶Returns the style sheet associated with the control, if any.
A style sheet allows named character and paragraph styles to be applied.
GetTextCursor
(self)¶Returns the text (normal) cursor.
Cursor
GetURLCursor
(self)¶Returns the cursor to be used over URLs.
Cursor
GetUncombinedStyle
(self, *args, **kw)¶Gets the attributes at the given position.
This function gets the uncombined style - that is, the attributes associated with the paragraph or character content, and not necessarily the combined attributes you see on the screen. To get the combined attributes, use GetStyle
.
If you specify (any) paragraph attribute in style’s flags, this function will fetch the paragraph attributes. Otherwise, it will return the character attributes.
GetUnscaledPoint
(self, pt)¶Returns an unscaled point.
pt (wx.Point) –
Point
GetUnscaledRect
(self, rect)¶Returns an unscaled rectangle.
rect (wx.Rect) –
Rect
GetValue
(self)¶Returns the content of the entire control as a string.
string
GetVerticalScrollbarEnabled
(self)¶Returns True
if the vertical scrollbar is enabled.
bool
GetVirtualAttributesEnabled
(self)¶Returns True
if this control can use virtual attributes and virtual text.
The default is False
.
bool
GetVisibleLineForCaretPosition
(self, caretPosition)¶Internal helper function returning the line for the visible caret position.
If the caret is shown at the very end of the line, it means the next character is actually on the following line. So this function gets the line we’re expecting to find if this is the case.
caretPosition (long) –
HasCharacterAttributes
(self, range, style)¶Test if this whole range has character attributes of the specified kind.
If any of the attributes are different within the range, the test fails.
You can use this to implement, for example, bold button updating. style must have flags indicating which attributes are of interest.
range (wx.richtext.RichTextRange) –
style (wx.richtext.RichTextAttr) –
bool
HasParagraphAttributes
(self, range, style)¶Test if this whole range has paragraph attributes of the specified kind.
If any of the attributes are different within the range, the test fails. You can use this to implement, for example, centering button updating. style must have flags indicating which attributes are of interest.
range (wx.richtext.RichTextRange) –
style (wx.richtext.RichTextAttr) –
bool
HasSelection
(self)¶Returns True
if there is a selection and the object containing the selection was the same as the current focus object.
bool
HasUnfocusedSelection
(self)¶Returns True
if there was a selection, whether or not the current focus object is the same as the selection’s container object.
bool
HitTest
(self, pt)¶Finds the character at the given position in pixels.
pt is in device coords (not adjusted for the client area origin nor for scrolling).
pt (wx.Point) –
tuple
( wx.TextCtrlHitTestResult, pos )
HitTestXY
(self, pt)¶Finds the character at the given position in pixels.
pt is in device coords (not adjusted for the client area origin nor for scrolling).
pt (wx.Point) –
tuple
( wx.TextCtrlHitTestResult, col, row )
Init
(self)¶Initialises the members of the control.
Invalidate
(self)¶Invalidates the whole buffer to trigger painting later.
IsDefaultStyleShowing
(self)¶Returns True
if the user has recently set the default style without moving the caret, and therefore the UI needs to reflect the default style and not the style at the caret.
Below is an example of code that uses this function to determine whether the UI should show that the current style is bold.
bool
See also
IsEditable
(self)¶Returns True
if the control is editable.
bool
IsEmpty
(self)¶Returns True
if the control is currently empty.
This is the same as GetValue
.empty() but can be much more efficient for the multiline controls containing big amounts of text.
bool
New in version 2.7.1.
IsModified
(self)¶Returns True
if the buffer has been modified.
bool
IsMultiLine
(self)¶Returns True
if the control is multiline.
bool
IsPositionVisible
(self, pos)¶Returns True
if the given position is visible on the screen.
pos (long) –
bool
IsSelectionAligned
(self, alignment)¶Returns True
if all of the selection is aligned according to the specified flag.
alignment (TextAttrAlignment) –
bool
IsSelectionBold
(self)¶Returns True
if all of the selection, or the content at the caret position, is bold.
bool
IsSelectionItalics
(self)¶Returns True
if all of the selection, or the content at the caret position, is italic.
bool
IsSelectionUnderlined
(self)¶Returns True
if all of the selection, or the content at the caret position, is underlined.
bool
IsSingleLine
(self)¶Returns True
if the control is single-line.
Currently wx.richtext.RichTextCtrl does not support single-line editing.
bool
Helper function implementing keyboard navigation.
keyCode (int) –
flags (int) –
bool
LayoutContent
(self, onlyVisibleRect=False)¶Lays out the buffer, which must be done before certain operations, such as setting the caret position.
This function should not normally be required by the application.
onlyVisibleRect (bool) –
bool
LineBreak
(self)¶Inserts a line break at the current insertion point.
A line break forces wrapping within a paragraph, and can be introduced by using this function, by appending the Char value RichTextLineBreakChar to text content, or by typing Shift-Return.
bool
LoadFile
(self, file, type=RICHTEXT_TYPE_ANY)¶Loads content into the control’s buffer using the given type.
If the specified type is wx.richtext.RICHTEXT_TYPE_ANY
, the type is deduced from the filename extension.
This function looks for a suitable wx.richtext.RichTextFileHandler object.
file (string) –
type (int) –
bool
MarkDirty
(self)¶Marks the buffer as modified.
MoveCaret
(self, pos, showAtLineStart=False, container=None)¶Move the caret to the given character position.
Please note that this does not update the current editing style from the new position; to do that, call wx.richtext.RichTextCtrl.SetInsertionPoint
instead.
pos (long) –
showAtLineStart (bool) –
container (wx.richtext.RichTextParagraphLayoutBox) –
bool
MoveCaretBack
(self, oldPosition)¶Move the caret one visual step forward: this may mean setting a flag and keeping the same position if we’re going from the end of one line to the start of the next, which may be the exact same caret position.
oldPosition (long) –
MoveCaretForward
(self, oldPosition)¶Move the caret one visual step forward: this may mean setting a flag and keeping the same position if we’re going from the end of one line to the start of the next, which may be the exact same caret position.
oldPosition (long) –
MoveDown
(self, noLines=1, flags=0)¶Moves the caret down.
noLines (int) –
flags (int) –
bool
MoveEnd
(self, flags=0)¶Moves to the end of the buffer.
flags (int) –
bool
MoveHome
(self, flags=0)¶Moves to the start of the buffer.
flags (int) –
bool
MoveLeft
(self, noPositions=1, flags=0)¶Moves left.
noPositions (int) –
flags (int) –
bool
MoveRight
(self, noPositions=1, flags=0)¶Moves right.
noPositions (int) –
flags (int) –
bool
MoveToLineEnd
(self, flags=0)¶Moves to the end of the line.
flags (int) –
bool
MoveToLineStart
(self, flags=0)¶Moves to the start of the line.
flags (int) –
bool
MoveToParagraphEnd
(self, flags=0)¶Moves to the end of the paragraph.
flags (int) –
bool
MoveToParagraphStart
(self, flags=0)¶Moves to the start of the paragraph.
flags (int) –
bool
MoveUp
(self, noLines=1, flags=0)¶Moves to the start of the paragraph.
noLines (int) –
flags (int) –
bool
Newline
(self)¶Inserts a new paragraph at the current insertion point.
bool
See also
NumberList
(self, *args, **kw)¶Numbers the paragraphs in the given range.
Pass flags to determine how the attributes are set.
Either the style definition or the name of the style definition (in the current sheet) can be passed.
flags is a bit list of the following:
wx.richtext.RICHTEXT_SETSTYLE_WITH_UNDO
: specifies that this command will be undoable.
wx.richtext.RICHTEXT_SETSTYLE_RENUMBER
: specifies that numbering should start from startFrom, otherwise existing attributes are used.
wx.richtext.RICHTEXT_SETSTYLE_SPECIFY_LEVEL
: specifies that listLevel should be used as the level for all paragraphs, otherwise the current indentation will be used.
See also
SetListStyle
, PromoteList
, ClearListStyle
.
NumberList (self, range, def=None, flags=RICHTEXT_SETSTYLE_WITH_UNDO, startFrom=1, specifiedLevel=-1)
range (wx.richtext.RichTextRange) –
flags (int) –
startFrom (int) –
specifiedLevel (int) –
bool
NumberList (self, range, defName, flags=RICHTEXT_SETSTYLE_WITH_UNDO, startFrom=1, specifiedLevel=-1)
range (wx.richtext.RichTextRange) –
defName (string) –
flags (int) –
startFrom (int) –
specifiedLevel (int) –
bool
OnCaptureLost
(self, event)¶event (wx.MouseCaptureLostEvent) –
OnChar
(self, event)¶event (wx.KeyEvent) –
OnClear
(self, event)¶Standard handler for the wx.ID_CLEAR
command.
event (wx.CommandEvent) –
OnContextMenu
(self, event)¶Shows a standard context menu with undo, redo, cut, copy, paste, clear, and select all commands.
event (wx.ContextMenuEvent) –
OnCopy
(self, event)¶Standard handler for the wx.ID_COPY
command.
event (wx.CommandEvent) –
OnCut
(self, event)¶Standard handler for the wx.ID_CUT
command.
event (wx.CommandEvent) –
OnDropFiles
(self, event)¶Loads the first dropped file.
event (wx.DropFilesEvent) –
OnEraseBackground
(self, event)¶event (wx.EraseEvent) –
OnIdle
(self, event)¶event (wx.IdleEvent) –
OnKillFocus
(self, event)¶event (wx.FocusEvent) –
OnLeftClick
(self, event)¶event (wx.MouseEvent) –
OnLeftDClick
(self, event)¶event (wx.MouseEvent) –
OnLeftUp
(self, event)¶event (wx.MouseEvent) –
OnMiddleClick
(self, event)¶event (wx.MouseEvent) –
OnMoveMouse
(self, event)¶event (wx.MouseEvent) –
OnPaint
(self, event)¶event (wx.PaintEvent) –
OnPaste
(self, event)¶Standard handler for the wx.ID_PASTE
command.
event (wx.CommandEvent) –
OnProperties
(self, event)¶Standard handler for property commands.
event (wx.CommandEvent) –
OnRedo
(self, event)¶Standard handler for the wx.ID_REDO
command.
event (wx.CommandEvent) –
OnRightClick
(self, event)¶event (wx.MouseEvent) –
OnScroll
(self, event)¶event (wx.ScrollWinEvent) –
OnSelectAll
(self, event)¶Standard handler for the wx.ID_SELECTALL
command.
event (wx.CommandEvent) –
OnSetFocus
(self, event)¶event (wx.FocusEvent) –
OnSize
(self, event)¶event (wx.SizeEvent) –
OnSysColourChanged
(self, event)¶event (wx.SysColourChangedEvent) –
OnTimer
(self, event)¶Respond to timer events.
event (wx.TimerEvent) –
OnUndo
(self, event)¶Standard handler for the wx.ID_UNDO
command.
event (wx.CommandEvent) –
OnUpdateClear
(self, event)¶Standard update handler for the wx.ID_CLEAR
command.
event (wx.UpdateUIEvent) –
OnUpdateCopy
(self, event)¶Standard update handler for the wx.ID_COPY
command.
event (wx.UpdateUIEvent) –
OnUpdateCut
(self, event)¶Standard update handler for the wx.ID_CUT
command.
event (wx.UpdateUIEvent) –
OnUpdatePaste
(self, event)¶Standard update handler for the wx.ID_PASTE
command.
event (wx.UpdateUIEvent) –
OnUpdateProperties
(self, event)¶Standard update handler for property commands.
event (wx.UpdateUIEvent) –
OnUpdateRedo
(self, event)¶Standard update handler for the wx.ID_REDO
command.
event (wx.UpdateUIEvent) –
OnUpdateSelectAll
(self, event)¶Standard update handler for the wx.ID_SELECTALL
command.
event (wx.UpdateUIEvent) –
OnUpdateUndo
(self, event)¶Standard update handler for the wx.ID_UNDO
command.
event (wx.UpdateUIEvent) –
PageDown
(self, noPages=1, flags=0)¶Moves one or more pages down.
noPages (int) –
flags (int) –
bool
PageUp
(self, noPages=1, flags=0)¶Moves one or more pages up.
noPages (int) –
flags (int) –
bool
PaintAboveContent
(self, WXUNUSED)¶Other user defined painting after everything else (i.e. all text) is painted.
WXUNUSED (wx.DC) –
New in version 2.9.1.
Paste
(self)¶Pastes content from the clipboard to the buffer.
PopStyleSheet
(self)¶Pops the style sheet from top of stack.
PositionCaret
(self, container=None)¶Internal function to position the visible caret according to the current caret position.
container (wx.richtext.RichTextParagraphLayoutBox) –
PositionToXY
(self, pos)¶Converts a text position to zero-based column and line numbers.
pos (long) –
tuple
( bool, x, y )
PrepareContent
(self, container)¶Prepares the content just before insertion (or after buffer reset).
Called by the same function in wx.richtext.RichTextBuffer. Currently is only called if undo mode is on.
container (wx.richtext.RichTextParagraphLayoutBox) –
PrepareContextMenu
(self, menu, pt, addPropertyCommands)¶Prepares the context menu, optionally adding appropriate property-editing commands.
Returns the number of property commands added.
ProcessBackKey
(self, event, flags)¶Processes the back key.
event (wx.KeyEvent) –
flags (int) –
bool
ProcessDelayedImageLoading
(self, *args, **kw)¶ProcessDelayedImageLoading (self, refresh)
Do delayed image loading and garbage-collect other images.
refresh (bool) –
bool
ProcessDelayedImageLoading (self, screenRect, box, loadCount)
screenRect (wx.Rect) –
loadCount (int) –
bool
ProcessMouseMovement
(self, container, obj, position, pos)¶Processes mouse movement in order to change the cursor.
container (wx.richtext.RichTextParagraphLayoutBox) –
obj (wx.richtext.RichTextObject) –
position (long) –
pos (wx.Point) –
bool
PromoteList
(self, *args, **kw)¶Promotes or demotes the paragraphs in the given range.
A positive promoteBy produces a smaller indent, and a negative number produces a larger indent. Pass flags to determine how the attributes are set. Either the style definition or the name of the style definition (in the current sheet) can be passed.
flags is a bit list of the following:
wx.richtext.RICHTEXT_SETSTYLE_WITH_UNDO
: specifies that this command will be undoable.
wx.richtext.RICHTEXT_SETSTYLE_RENUMBER
: specifies that numbering should start from startFrom, otherwise existing attributes are used.
wx.richtext.RICHTEXT_SETSTYLE_SPECIFY_LEVEL
: specifies that listLevel should be used as the level for all paragraphs, otherwise the current indentation will be used.
See also
See also
SetListStyle
, ClearListStyle
.
PromoteList (self, promoteBy, range, def=None, flags=RICHTEXT_SETSTYLE_WITH_UNDO, specifiedLevel=-1)
promoteBy (int) –
range (wx.richtext.RichTextRange) –
flags (int) –
specifiedLevel (int) –
bool
PromoteList (self, promoteBy, range, defName, flags=RICHTEXT_SETSTYLE_WITH_UNDO, specifiedLevel=-1)
promoteBy (int) –
range (wx.richtext.RichTextRange) –
defName (string) –
flags (int) –
specifiedLevel (int) –
bool
PushStyleSheet
(self, styleSheet)¶Push the style sheet to top of stack.
styleSheet (wx.richtext.RichTextStyleSheet) –
bool
Redo
(self)¶Redoes the current command.
RefreshForSelectionChange
(self, oldSelection, newSelection)¶Refreshes the area affected by a selection change.
oldSelection (wx.richtext.RichTextSelection) –
newSelection (wx.richtext.RichTextSelection) –
bool
Remove
(self, from_, to_)¶Removes the content in the specified range.
from_ (long) –
to_ (long) –
Replace
(self, from_, to_, value)¶Replaces the content in the specified range with the string specified by value.
from_ (long) –
to_ (long) –
value (string) –
RequestDelayedImageProcessing
(self)¶Request delayed image processing.
SaveFile
(self, file="", type=RICHTEXT_TYPE_ANY)¶Saves the buffer content using the given type.
If the specified type is wx.richtext.RICHTEXT_TYPE_ANY
, the type is deduced from the filename extension.
This function looks for a suitable wx.richtext.RichTextFileHandler object.
file (string) –
type (int) –
bool
ScrollIntoView
(self, position, keyCode)¶Scrolls position into view.
This function takes a caret position.
position (long) –
keyCode (int) –
bool
SelectAll
(self)¶Selects all the text in the buffer.
SelectNone
(self)¶Cancels any selection.
SelectWord
(self, position)¶Selects the word at the given character position.
position (long) –
bool
SetAndShowDefaultStyle
(self, attr)¶Sets attr
as the default style and tells the control that the UI should reflect this attribute until the user moves the caret.
attr (wx.richtext.RichTextAttr) –
See also
SetBasicStyle
(self, style)¶Sets the basic (overall) style.
This is the style of the whole buffer before further styles are applied, unlike the default style, which only affects the style currently being applied (for example, setting the default style to bold will cause subsequently inserted text to be bold).
style (wx.richtext.RichTextAttr) –
SetCaretAtLineStart
(self, atStart)¶Sets a flag to remember that we are showing the caret position at the start of a line instead of at the end of the previous one.
atStart (bool) –
SetCaretPosition
(self, position, showAtLineStart=False)¶Sets the caret position.
The caret position is the character position just before the caret. A value of -1 means the caret is at the start of the buffer. Please note that this does not update the current editing style from the new position or cause the actual caret to be refreshed; to do that, call wx.richtext.RichTextCtrl.SetInsertionPoint
instead.
position (long) –
showAtLineStart (bool) –
SetCaretPositionAfterClick
(self, container, position, hitTestFlags, extendSelection=False)¶Sets up the caret for the given position and container, after a mouse click.
container (wx.richtext.RichTextParagraphLayoutBox) –
position (long) –
hitTestFlags (int) –
extendSelection (bool) –
bool
SetCaretPositionForDefaultStyle
(self, pos)¶Set the caret position for the default style that the user is selecting.
pos (long) –
SetDefaultStyle
(self, *args, **kw)¶Sets the current default style, which can be used to change how subsequently inserted text is displayed.
SetDefaultStyle (self, style)
style (wx.TextAttr) –
bool
SetDefaultStyle (self, style)
style (wx.richtext.RichTextAttr) –
bool
SetDefaultStyleToCursorStyle
(self)¶Sets the default style to the style under the cursor.
bool
SetDelayedImageProcessingRequired
(self, b)¶Sets the flag indicating that delayed image processing is required.
b (bool) –
SetDelayedImageProcessingTime
(self, t)¶Sets the last time delayed image processing was performed.
t (long) –
SetDelayedLayoutThreshold
(self, threshold)¶Sets the size of the buffer beyond which layout is delayed during resizing.
This optimizes sizing for large buffers. The default is 20000.
threshold (long) –
SetDimensionScale
(self, dimScale, refresh=False)¶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.
dimScale (float) –
refresh (bool) –
SetDragStartTime
(self, st)¶Set the possible Drag’n’Drop start time.
st (wx.DateTime) –
SetDragging
(self, dragging)¶Sets a flag to remember if we are extending a selection.
dragging (bool) –
SetEditable
(self, editable)¶Makes the control editable, or not.
editable (bool) –
SetFilename
(self, filename)¶Sets the current filename.
filename (string) –
SetFocusObject
(self, obj, setCaretPosition=True)¶Sets the wx.richtext.RichTextObject object that currently has the editing focus.
obj (wx.richtext.RichTextParagraphLayoutBox) – The wx.richtext.RichTextObject to set focus on.
setCaretPosition (bool) – Optionally set the caret position.
bool
SetFont
(self, font)¶Sets the font, and also the basic and default attributes (see wx.richtext.RichTextCtrl.SetDefaultStyle
).
font (wx.Font) –
bool
SetFontScale
(self, fontScale, refresh=False)¶Sets the scale factor for displaying fonts, for example for more comfortable editing.
fontScale (float) –
refresh (bool) –
SetFullLayoutRequired
(self, b)¶b (bool) –
SetFullLayoutSavedPosition
(self, p)¶p (long) –
SetFullLayoutTime
(self, t)¶t (long) –
SetHandlerFlags
(self, flags)¶Sets flags that change the behaviour of loading or saving.
See the documentation for each handler class to see what flags are relevant for each handler.
flags (int) –
SetHint
(self, hint)¶Sets a hint shown in an empty unfocused text control.
The hints are usually used to indicate to the user what is supposed to be entered into the given entry field, e.g. a common use of them is to show an explanation of what can be entered in a wx.SearchCtrl.
The hint is shown (usually greyed out) for an empty control until it gets focus and is shown again if the control loses it and remains empty. It won’t be shown once the control has a non-empty value, although it will be shown again if the control contents is cleared. Because of this, it generally only makes sense to use hints with the controls which are initially empty.
Notice that hints are known as cue banners under MSW or placeholder strings under macOS.
For the platforms without native hints support, the implementation has several known limitations. Notably, the hint display will not be properly updated if you change wx.TextEntry contents programmatically when the hint is displayed using methods other than SetValue
or ChangeValue
or others which use them internally (e.g. Clear
). In other words, currently you should avoid calling methods such as WriteText
or Replace
when using hints and the text control is empty. If you bind to the control’s focus and wxEVT_TEXT events, you must call wx.Event.Skip
on them so that the generic implementation works correctly.
Another limitation is that hints are ignored for the controls with TE_PASSWORD
style.
hint (string) –
bool
New in version 2.9.0.
Note
Currently implemented natively on Windows (Vista and later only), macOS and GTK+ (3.2 and later).
Note
Hints can be used for single line text controls under all platforms, but only MSW and GTK+ 2 support them for multi-line text controls, they are ignored for them under the other platforms.
SetInsertionPoint
(self, pos)¶Sets the insertion point and causes the current editing style to be taken from the new position (unlike wx.richtext.RichTextCtrl.SetCaretPosition
).
pos (long) –
SetInsertionPointEnd
(self)¶Sets the insertion point to the end of the text control.
SetInternalSelectionRange
(self, range)¶Sets the selection range in character positions.
-2, -2 means no selection -1, -1 means select everything. The range is in internal format, i.e. a single character selection is denoted by (n, n)
range (wx.richtext.RichTextRange) –
SetListStyle
(self, *args, **kw)¶Sets the list attributes for the given range, passing flags to determine how the attributes are set.
Either the style definition or the name of the style definition (in the current sheet) can be passed. flags is a bit list of the following:
wx.richtext.RICHTEXT_SETSTYLE_WITH_UNDO
: specifies that this command will be undoable.
wx.richtext.RICHTEXT_SETSTYLE_RENUMBER
: specifies that numbering should start from startFrom, otherwise existing attributes are used.
wx.richtext.RICHTEXT_SETSTYLE_SPECIFY_LEVEL
: specifies that listLevel should be used as the level for all paragraphs, otherwise the current indentation will be used.
See also
NumberList
, PromoteList
, ClearListStyle
.
SetListStyle (self, range, styleDef, flags=RICHTEXT_SETSTYLE_WITH_UNDO, startFrom=1, specifiedLevel=-1)
range (wx.richtext.RichTextRange) –
styleDef (wx.richtext.RichTextListStyleDefinition) –
flags (int) –
startFrom (int) –
specifiedLevel (int) –
bool
SetListStyle (self, range, defName, flags=RICHTEXT_SETSTYLE_WITH_UNDO, startFrom=1, specifiedLevel=-1)
range (wx.richtext.RichTextRange) –
defName (string) –
flags (int) –
startFrom (int) –
specifiedLevel (int) –
bool
SetMargins
(self, *args, **kw)¶Attempts to set the control margins.
When margins are given as wx.Point, x indicates the left and y the top margin. Use -1 to indicate that an existing value should be used.
True
if setting of all requested margins was successful.
New in version 2.9.1.
SetMargins (self, pt)
pt (wx.Point) –
bool
SetMargins (self, left, top=-1)
left (int) –
top (int) –
bool
SetMaxLength
(self, len)¶Sets the maximum number of characters that may be entered in a single line text control.
For compatibility only; currently does nothing.
len (long) –
SetModified
(self, modified)¶modified (bool) –
SetPreDrag
(self, pd)¶Set if we’re trying to start Drag’n’Drop.
pd (bool) –
SetProperties
(self, range, properties, flags=RICHTEXT_SETPROPERTIES_WITH_UNDO)¶Sets the properties for the given range, passing flags to determine how the attributes are set.
You can merge properties or replace them.
The end point of range is specified as the last character position of the span of text, plus one. So, for example, to set the properties for a character at position 5, use the range (5,6).
flags may contain a bit list of the following values:
RICHTEXT_SETSPROPERTIES_NONE
: no flag.
wx.richtext.RICHTEXT_SETPROPERTIES_WITH_UNDO
: specifies that this operation should be undoable.
wx.richtext.RICHTEXT_SETPROPERTIES_PARAGRAPHS_ONLY
: specifies that the properties should only be applied to paragraphs, and not the content.
wx.richtext.RICHTEXT_SETPROPERTIES_CHARACTERS_ONLY
: specifies that the properties should only be applied to characters, and not the paragraph.
wx.richtext.RICHTEXT_SETPROPERTIES_RESET
: resets (clears) the existing properties before applying the new properties.
wx.richtext.RICHTEXT_SETPROPERTIES_REMOVE
: removes the specified properties.
range (wx.richtext.RichTextRange) –
properties (wx.richtext.RichTextProperties) –
flags (int) –
bool
SetScale
(self, scale, refresh=False)¶Sets an overall scale factor for displaying and editing the content.
scale (float) –
refresh (bool) –
SetSelection
(self, *args, **kw)¶Sets the selection to the given range.
The end point of range is specified as the last character position of the span of text, plus one.
So, for example, to set the selection for a character at position 5, use the range (5,6).
SetSelection (self, from_, to_)
from_ (long) –
to_ (long) –
SetSelection (self, sel)
sel (wx.richtext.RichTextSelection) –
SetSelectionAnchor
(self, anchor)¶Sets an anchor so we know how to extend the selection.
It’s a caret position since it’s between two characters.
anchor (long) –
SetSelectionAnchorObject
(self, anchor)¶Sets the anchor object if selecting multiple containers.
anchor (wx.richtext.RichTextObject) –
SetSelectionRange
(self, range)¶Sets the selection to the given range.
The end point of range is specified as the last character position of the span of text, plus one.
So, for example, to set the selection for a character at position 5, use the range (5,6).
range (wx.richtext.RichTextRange) –
SetStyle
(self, *args, **kw)¶SetStyle (self, start, end, style)
Sets the attributes for the given range.
The end point of range is specified as the last character position of the span of text, plus one.
So, for example, to set the style for a character at position 5, use the range (5,6).
start (long) –
end (long) –
style (wx.TextAttr) –
bool
SetStyle (self, start, end, style)
Sets the attributes for the given range.
The end point of range is specified as the last character position of the span of text, plus one.
So, for example, to set the style for a character at position 5, use the range (5,6).
start (long) –
end (long) –
style (wx.richtext.RichTextAttr) –
bool
SetStyle (self, range, style)
Sets the attributes for the given range.
The end point of range is specified as the last character position of the span of text, plus one.
So, for example, to set the style for a character at position 5, use the range (5,6).
range (wx.richtext.RichTextRange) –
style (wx.TextAttr) –
bool
SetStyle (self, range, style)
Sets the attributes for the given range.
The end point of range is specified as the last character position of the span of text, plus one.
So, for example, to set the style for a character at position 5, use the range (5,6).
range (wx.richtext.RichTextRange) –
style (wx.richtext.RichTextAttr) –
bool
SetStyle (self, obj, textAttr, flags=RICHTEXT_SETSTYLE_WITH_UNDO)
Sets the attributes for a single object.
obj (wx.richtext.RichTextObject) –
textAttr (wx.richtext.RichTextAttr) –
flags (int) –
SetStyleEx
(self, range, style, flags=RICHTEXT_SETSTYLE_WITH_UNDO)¶Sets the attributes for the given range, passing flags to determine how the attributes are set.
The end point of range is specified as the last character position of the span of text, plus one. So, for example, to set the style for a character at position 5, use the range (5,6).
flags may contain a bit list of the following values:
wx.richtext.RICHTEXT_SETSTYLE_NONE
: no style flag.
wx.richtext.RICHTEXT_SETSTYLE_WITH_UNDO
: specifies that this operation should be undoable.
wx.richtext.RICHTEXT_SETSTYLE_OPTIMIZE
: specifies that the style should not be applied if the combined style at this point is already the style in question.
wx.richtext.RICHTEXT_SETSTYLE_PARAGRAPHS_ONLY
: specifies that the style should only be applied to paragraphs, and not the content. This allows content styling to be preserved independently from that of e.g. a named paragraph style.
wx.richtext.RICHTEXT_SETSTYLE_CHARACTERS_ONLY
: specifies that the style should only be applied to characters, and not the paragraph. This allows content styling to be preserved independently from that of e.g. a named paragraph style.
wx.richtext.RICHTEXT_SETSTYLE_RESET
: resets (clears) the existing style before applying the new style.
wx.richtext.RICHTEXT_SETSTYLE_REMOVE
: removes the specified style. Only the style flags are used in this operation.
range (wx.richtext.RichTextRange) –
style (wx.richtext.RichTextAttr) –
flags (int) –
bool
SetStyleSheet
(self, styleSheet)¶Sets the style sheet associated with the control.
A style sheet allows named character and paragraph styles to be applied.
styleSheet (wx.richtext.RichTextStyleSheet) –
SetValue
(self, value)¶Replaces existing content with the given text.
value (string) –
SetupScrollbars
(self, atTop=False)¶A helper function setting up scrollbars, for example after a resize.
atTop (bool) –
ShouldInheritColours
(self)¶Return True
from here to allow the colours of this window to be changed by InheritAttributes
.
Returning False
forbids inheriting them from the parent window.
The base class version returns False
, but this method is overridden in wx.Control where it returns True
.
bool
ShowContextMenu
(self, menu, pt, addPropertyCommands)¶Shows the given context menu, optionally adding appropriate property-editing commands for the current position in the object hierarchy.
ShowPosition
(self, pos)¶Scrolls the buffer so that the given position is in view.
pos (long) –
StartCellSelection
(self, table, newCell)¶Starts selecting table cells.
table (wx.richtext.RichTextTable) –
newCell (wx.richtext.RichTextParagraphLayoutBox) –
bool
StoreFocusObject
(self, obj)¶Setter for m_focusObject.
SuppressingUndo
(self)¶Returns True
if undo history suppression is on.
bool
Undo
(self)¶Undoes the command at the top of the command history, if there is one.
WordLeft
(self, noPages=1, flags=0)¶Moves a number of words to the left.
noPages (int) –
flags (int) –
bool
WordRight
(self, noPages=1, flags=0)¶Move a number of words to the right.
noPages (int) –
flags (int) –
bool
WriteField
(self, fieldType, properties, textAttr=RichTextAttr())¶Writes a field at the current insertion point.
fieldType (string) – The field type, matching an existing field type definition.
properties (wx.richtext.RichTextProperties) – Extra data for the field.
textAttr (wx.richtext.RichTextAttr) – Optional attributes.
WriteImage
(self, *args, **kw)¶WriteImage (self, image, bitmapType=BITMAP_TYPE_PNG, textAttr=RichTextAttr())
Write a bitmap or image at the current insertion point.
Supply an optional type to use for internal and file storage of the raw data.
image (wx.Image) –
bitmapType (BitmapType) –
textAttr (wx.richtext.RichTextAttr) –
bool
WriteImage (self, bitmap, bitmapType=BITMAP_TYPE_PNG, textAttr=RichTextAttr())
Write a bitmap or image at the current insertion point.
Supply an optional type to use for internal and file storage of the raw data.
bitmap (wx.Bitmap) –
bitmapType (BitmapType) –
textAttr (wx.richtext.RichTextAttr) –
bool
WriteImage (self, filename, bitmapType, textAttr=RichTextAttr())
Loads an image from a file and writes it at the current insertion point.
filename (string) –
bitmapType (BitmapType) –
textAttr (wx.richtext.RichTextAttr) –
bool
WriteImage (self, imageBlock, textAttr=RichTextAttr())
Writes an image block at the current insertion point.
imageBlock (wx.richtext.RichTextImageBlock) –
textAttr (wx.richtext.RichTextAttr) –
bool
WriteTable
(self, rows, cols, tableAttr=RichTextAttr(), cellAttr=RichTextAttr())¶Write a table at the current insertion point, returning the table.
You can then call SetFocusObject
to set the focus to the new object.
rows (int) –
cols (int) –
tableAttr (wx.richtext.RichTextAttr) –
cellAttr (wx.richtext.RichTextAttr) –
WriteText
(self, text)¶Writes text at the current position.
text (string) –
WriteTextBox
(self, textAttr=RichTextAttr())¶Write a text box at the current insertion point, returning the text box.
You can then call SetFocusObject
to set the focus to the new object.
textAttr (wx.richtext.RichTextAttr) –
XYToPosition
(self, x, y)¶Translates from column and line number to position.
x (long) –
y (long) –
long
BasicStyle
¶See GetBasicStyle
and SetBasicStyle
CaretAtLineStart
¶CaretPosition
¶See GetCaretPosition
and SetCaretPosition
CaretPositionForDefaultStyle
¶See GetCaretPositionForDefaultStyle
and SetCaretPositionForDefaultStyle
CommandProcessor
¶ContextMenu
¶See GetContextMenu
and SetContextMenu
ContextMenuPropertiesInfo
¶DefaultStyle
¶See GetDefaultStyle
and SetDefaultStyle
DefaultStyleEx
¶DelayedImageLoading
¶DelayedImageProcessingRequired
¶See GetDelayedImageProcessingRequired
and SetDelayedImageProcessingRequired
DelayedImageProcessingTime
¶See GetDelayedImageProcessingTime
and SetDelayedImageProcessingTime
DelayedLayoutThreshold
¶DimensionScale
¶See GetDimensionScale
and SetDimensionScale
DragStartPoint
¶See GetDragStartPoint
and SetDragStartPoint
DragStartTime
¶See GetDragStartTime
and SetDragStartTime
Dragging
¶See GetDragging
and SetDragging
Filename
¶See GetFilename
and SetFilename
FirstVisiblePoint
¶FirstVisiblePosition
¶FocusObject
¶See GetFocusObject
and SetFocusObject
FontScale
¶See GetFontScale
and SetFontScale
FullLayoutRequired
¶FullLayoutSavedPosition
¶See GetFullLayoutSavedPosition
and SetFullLayoutSavedPosition
FullLayoutTime
¶See GetFullLayoutTime
and SetFullLayoutTime
HandlerFlags
¶See GetHandlerFlags
and SetHandlerFlags
ImagesEnabled
¶See GetImagesEnabled
InsertionPoint
¶See GetInsertionPoint
and SetInsertionPoint
InternalSelectionRange
¶LastPosition
¶See GetLastPosition
Margins
¶See GetMargins
and SetMargins
NumberOfLines
¶See GetNumberOfLines
PreDrag
¶See GetPreDrag
and SetPreDrag
Selection
¶See GetSelection
and SetSelection
SelectionAnchor
¶See GetSelectionAnchor
and SetSelectionAnchor
SelectionAnchorObject
¶SelectionRange
¶See GetSelectionRange
and SetSelectionRange
StringSelection
¶StyleSheet
¶See GetStyleSheet
and SetStyleSheet
TextCursor
¶See GetTextCursor
and SetTextCursor
URLCursor
¶See GetURLCursor
and SetURLCursor
VerticalScrollbarEnabled
¶VirtualAttributesEnabled
¶