wx.richtext.RichTextCtrl¶
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.
Window Styles¶
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.
Class Hierarchy¶
Control Appearance¶
Methods Summary¶
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 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. |
|
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. |
Properties Summary¶
Class API¶
- class wx.richtext.RichTextCtrl(Control)¶
Possible constructors:
RichTextCtrl() -> None RichTextCtrl(parent, id=-1, value='', pos=DefaultPosition, size=DefaultSize, style=RE_MULTILINE, validator=DefaultValidator, name=TextCtrlNameStr) -> None
RichTextCtrl provides a generic, ground-up implementation of a text control capable of showing multiple styles and images.
Methods¶
- __init__(self, *args, **kw)¶
-
__init__ (self)
Default constructor.
- Return type:
None
__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.
- Parameters:
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.
- Return type:
None
See also
- AddImage(self, image)¶
Adds an image to the control’s buffer.
- Parameters:
image (wx.Image)
- Return type:
- AddParagraph(self, text)¶
Adds a new paragraph of text to the end of the buffer.
- Parameters:
text (string)
- Return type:
- AppendText(self, text)¶
Sets the insertion point to the end of the buffer and writes the text.
- Parameters:
text (string)
- Return type:
None
- ApplyAlignmentToSelection(self, alignment)¶
Applies the given alignment to the selection or the default style (undoable).
For alignment values, see wx.TextAttr.
- Parameters:
alignment (TextAttrAlignment)
- Return type:
bool
- ApplyBoldToSelection(self)¶
Apples bold to the selection or the default style (undoable).
- Return type:
bool
- ApplyItalicToSelection(self)¶
Applies italic to the selection or the default style (undoable).
- Return type:
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 withSetStyleSheet
is used. Currently this applies paragraph styles only.- Parameters:
styleDef (wx.richtext.RichTextStyleDefinition)
- Return type:
bool
- ApplyStyleSheet(self, styleSheet=None)¶
Applies the style sheet to the buffer, for example if the styles have changed.
- Parameters:
styleSheet (wx.richtext.RichTextStyleSheet)
- Return type:
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.
- Parameters:
flags (int)
- Return type:
bool
- ApplyUnderlineToSelection(self)¶
Applies underline to the selection or the default style (undoable).
- Return type:
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.
- Parameters:
choices (list of strings)
- Return type:
bool
- Returns:
True
if the auto-completion was enabled orFalse
if the operation failed, typically because auto-completion is not supported by the current platform.
Added 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.
- Parameters:
completer (wx.TextCompleter) – The object to be used for generating completions if not
None
. If it isNone
, 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 returnsFalse
).- Return type:
bool
- Returns:
True
if the auto-completion was enabled orFalse
if the operation failed, typically because auto-completion is not supported by the current platform.
Added in version 2.9.2.
See also
- 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.
- Return type:
bool
- Returns:
True
if the auto-completion was enabled orFalse
if the operation failed, typically because auto-completion is not supported by the current platform.
Added 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.
- Return type:
bool
- Returns:
True
if the auto-completion was enabled orFalse
if the operation failed, typically because auto-completion is not supported by the current platform.
Added in version 2.9.0.
See also
- BatchingUndo(self)¶
Returns
True
if undo commands are being batched.- Return type:
bool
- BeginAlignment(self, alignment)¶
Begins using alignment.
For alignment values, see wx.TextAttr.
- Parameters:
alignment (TextAttrAlignment)
- Return type:
bool
- BeginBatchUndo(self, cmdName)¶
Starts batching undo history for commands.
- Parameters:
cmdName (string)
- Return type:
bool
- BeginBold(self)¶
Begins using bold.
- Return type:
bool
- BeginCharacterStyle(self, characterStyle)¶
Begins using the named character style.
- Parameters:
characterStyle (string)
- Return type:
bool
- BeginFontSize(self, pointSize)¶
Begins using the given point size.
- Parameters:
pointSize (int)
- Return type:
bool
- BeginItalic(self)¶
Begins using italic.
- Return type:
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.
- Parameters:
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.
- Return type:
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.
- Parameters:
lineSpacing (int)
- Return type:
bool
- BeginListStyle(self, listStyle, level=1, number=1)¶
Begins using a specified 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 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.
- 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 applying the 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 symbol bullet.
- Parameters:
bulletName (string)
leftIndent (int)
leftSubIndent (int)
bulletStyle (int)
- Return type:
bool
- BeginStyle(self, style)¶
Begins applying a style.
- Parameters:
style (wx.richtext.RichTextAttr)
- Return type:
bool
- BeginSuppressUndo(self)¶
Starts suppressing undo history for commands.
- 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 underlining.
- Return type:
bool
- CanCopy(self)¶
Returns
True
if selected content can be copied to the clipboard.- Return type:
bool
- CanCut(self)¶
Returns
True
if selected content can be copied to the clipboard and deleted.- Return type:
bool
- CanDeleteRange(self, container, range)¶
Can we delete this range? Sends an event to the control.
- Parameters:
container (wx.richtext.RichTextParagraphLayoutBox)
range (wx.richtext.RichTextRange)
- Return type:
bool
- CanDeleteSelection(self)¶
Returns
True
if selected content can be deleted.- Return type:
bool
- CanEditProperties(self, obj)¶
Returns
True
if we can edit the object’s properties via a GUI.- Parameters:
- Return type:
bool
- CanInsertContent(self, container, pos)¶
Can we insert content at this position? Sends an event to the control.
- Parameters:
container (wx.richtext.RichTextParagraphLayoutBox)
pos (long)
- Return type:
bool
- CanPaste(self)¶
Returns
True
if the clipboard content can be pasted to the buffer.- Return type:
bool
- CanRedo(self)¶
Returns
True
if there is a command in the command history that can be redone.- Return type:
bool
- CanUndo(self)¶
Returns
True
if there is a command in the command history that can be undone.- Return type:
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 toChangeValue
.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 toSetValue
.See User Generated Events vs Programmatically Generated Events for more information.
- Parameters:
value (string) – The new value to set. It may contain newline characters if the text control is multi-line.
- Return type:
None
Added in version 2.7.1.
- Clear(self)¶
Clears the buffer content, leaving a single empty paragraph.
Cannot be undone.
- Return type:
None
- static ClearAvailableFontNames()¶
Clears the cache of available font names.
- Return type:
None
- 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.
- Parameters:
range (wx.richtext.RichTextRange)
flags (int)
- Return type:
bool
See also
- Command(self, event)¶
Sends the event to the control.
- Parameters:
event (wx.CommandEvent)
- Return type:
None
- Copy(self)¶
Copies the selected content (if any) to the clipboard.
- Return type:
None
- Create(self, parent, id=-1, value='', pos=DefaultPosition, size=DefaultSize, style=RE_MULTILINE, validator=DefaultValidator, name=TextCtrlNameStr)¶
Creates the underlying window.
- Parameters:
parent (wx.Window)
id (wx.WindowID)
value (string)
pos (wx.Point)
size (wx.Size)
style (long)
validator (wx.Validator)
name (string)
- Return type:
bool
- Cut(self)¶
Copies the selected content (if any) to the clipboard and deletes the selection.
This is undoable.
- Return type:
None
- Delete(self, range)¶
Deletes the content within the given range.
- Parameters:
range (wx.richtext.RichTextRange)
- Return type:
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.
- Return type:
None
- DiscardEdits(self)¶
Sets the buffer’s modified status to
False
, and clears the buffer’s command history.- Return type:
None
- DoGetValue(self)¶
- Return type:
str
- DoLayoutBuffer(self, buffer, dc, context, rect, parentRect, flags)¶
Implements layout.
An application may override this to perform operations before or after layout.
- Parameters:
buffer (wx.richtext.RichTextBuffer)
dc (wx.DC)
context (wx.richtext.RichTextDrawingContext)
rect (wx.Rect)
parentRect (wx.Rect)
flags (int)
- Return type:
None
- 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.
- Parameters:
file (string)
fileType (int)
- Return type:
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.
- Parameters:
file (string)
fileType (int)
- Return type:
bool
- DoThaw(self)¶
- Return type:
None
- DoWriteText(self, value, flags=0)¶
- Parameters:
value (string)
flags (int)
- Return type:
None
- DoesSelectionHaveTextEffectFlag(self, flag)¶
Returns
True
if all of the selection, or the content at the current caret position, has the supplied TextAttrEffects flag(s).- Parameters:
flag (int)
- Return type:
bool
- EditProperties(self, obj, parent)¶
Edits the object’s properties via a GUI.
- Parameters:
parent (wx.Window)
- Return type:
bool
- EnableDelayedImageLoading(self, b)¶
Enable or disable delayed image loading.
- Parameters:
b (bool)
- Return type:
None
- EnableImages(self, b)¶
Enable or disable images.
- Parameters:
b (bool)
- Return type:
None
- EnableVerticalScrollbar(self, enable)¶
Enable or disable the vertical scrollbar.
- Parameters:
enable (bool)
- Return type:
None
- EnableVirtualAttributes(self, b)¶
Pass
True
to let the control use virtual attributes.The default is
False
.- Parameters:
b (bool)
- Return type:
None
- EndAlignment(self)¶
Ends alignment.
- Return type:
bool
- EndAllStyles(self)¶
Ends application of all styles in the current style stack.
- Return type:
bool
- EndBatchUndo(self)¶
Ends batching undo command history.
- Return type:
bool
- EndBold(self)¶
Ends using bold.
- Return type:
bool
- EndCharacterStyle(self)¶
Ends application of a named character style.
- Return type:
bool
- EndFont(self)¶
Ends using a font.
- Return type:
bool
- EndFontSize(self)¶
Ends using a 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 using a specified list style.
- Return type:
bool
- EndNumberedBullet(self)¶
Ends application of a numbered bullet.
- Return type:
bool
- EndParagraphSpacing(self)¶
Ends paragraph spacing.
- Return type:
bool
- EndParagraphStyle(self)¶
Ends application of a named paragraph style.
- Return type:
bool
- EndRightIndent(self)¶
Ends right indent.
- Return type:
bool
- EndStandardBullet(self)¶
Begins applying a standard bullet.
- Return type:
bool
- EndStyle(self)¶
Ends the current style.
- Return type:
bool
- EndSuppressUndo(self)¶
Ends suppressing undo command history.
- Return type:
bool
- EndSymbolBullet(self)¶
Ends applying a symbol bullet.
- Return type:
bool
- EndTextColour(self)¶
Ends applying a text colour.
- Return type:
bool
- EndURL(self)¶
Ends applying a URL.
- Return type:
bool
- EndUnderline(self)¶
End applying underlining.
- Return type:
bool
- ExtendCellSelection(self, table, noRowSteps, noColSteps)¶
Extends a table selection in the given direction.
- Parameters:
table (wx.richtext.RichTextTable)
noRowSteps (int)
noColSteps (int)
- Return type:
bool
- ExtendSelection(self, oldPosition, newPosition, flags)¶
Helper function for extending the selection, returning
True
if the selection was changed.Selections are in caret positions.
- Parameters:
oldPosition (long)
newPosition (long)
flags (int)
- Return type:
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).
- Parameters:
position (long)
hitTestFlags (int)
container (wx.richtext.RichTextParagraphLayoutBox)
caretLineStart (bool)
- Return type:
int
- FindContainerAtPoint(self, pt, position, hit, hitObj, flags=0)¶
Finds the container at the given point, which is assumed to be in client coordinates.
- Parameters:
pt (wx.Point)
position (long)
hit (int)
hitObj (wx.richtext.RichTextObject)
flags (int)
- Return type:
- FindNextWordPosition(self, direction=1)¶
Helper function for finding the caret position for the next word.
Direction is 1 (forward) or -1 (backwards).
- Parameters:
direction (int)
- Return type:
int
- 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.
- Parameters:
pos (long)
isNumberedList (bool)
- Return type:
- ForceDelayedLayout(self)¶
- Return type:
None
- 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.
- Return type:
None
Added 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.
- Parameters:
caretPos (long)
- Return type:
int
- static GetAvailableFontNames()¶
Font names take a long time to retrieve, so cache them (on demand).
- Return type:
List[str]
- 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).
- Return type:
- GetBuffer(self)¶
Returns the buffer associated with the control.
- Return type:
- 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.- Return type:
bool
- GetCaretPosition(self)¶
Returns the current caret position.
- Return type:
int
- 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.
- Return type:
int
- 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.
- static GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)¶
- Parameters:
variant (WindowVariant)
- Return type:
VisualAttributes
- GetCommandProcessor(self)¶
Gets the command processor associated with the control’s buffer.
- Return type:
- GetContextMenu(self)¶
Returns the current context menu.
- Return type:
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.
- Return type:
- GetDefaultStyleEx(self)¶
Returns the current default style, which can be used to change how subsequently inserted text is displayed.
- Return type:
- GetDelayedImageLoading(self)¶
Returns
True
if delayed image loading is enabled.- Return type:
bool
- GetDelayedImageProcessingRequired(self)¶
Gets the flag indicating that delayed image processing is required.
- Return type:
bool
- GetDelayedImageProcessingTime(self)¶
Returns the last time delayed image processing was performed.
- Return type:
int
- 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.
- Return type:
int
- GetDimensionScale(self)¶
Returns the scale factor for displaying certain dimensions such as indentation and inter-paragraph spacing.
- Return type:
float
- GetDragStartPoint(self)¶
Get the possible Drag’n’Drop start point.
- Return type:
Point
- GetDragStartTime(self)¶
Get the possible Drag’n’Drop start time.
- Return type:
DateTime
- GetDragging(self)¶
Returns
True
if we are extending a selection.- Return type:
bool
- GetFilename(self)¶
Gets the current filename associated with the control.
- Return type:
str
- GetFirstVisiblePoint(self)¶
Returns the first visible point in the window.
- Return type:
Point
- GetFirstVisiblePosition(self)¶
Returns the first visible position in the current view.
- Return type:
int
- 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.
- Return type:
- GetFontScale(self)¶
Returns the scale factor for displaying fonts, for example for more comfortable editing.
- Return type:
float
- GetFullLayoutRequired(self)¶
- Return type:
bool
- GetFullLayoutSavedPosition(self)¶
- Return type:
int
- GetFullLayoutTime(self)¶
- Return type:
int
- 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.
- Return type:
int
- GetHint(self)¶
Returns the current hint string.
See
SetHint
for more information about hints.- Return type:
str
Added in version 2.9.0.
- GetImagesEnabled(self)¶
Returns
True
if images are enabled.- Return type:
bool
- GetInsertionPoint(self)¶
Returns the current insertion point.
- Return type:
int
- 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)
- Return type:
- GetLastPosition(self)¶
Returns the last position in the buffer.
- Return type:
wx.TextPos
- GetLineLength(self, lineNo)¶
Returns the length of the specified line in characters.
- Parameters:
lineNo (long)
- Return type:
int
- GetLineText(self, lineNo)¶
Returns the text for the given line.
- Parameters:
lineNo (long)
- Return type:
str
- GetLogicalPoint(self, ptPhysical)¶
Transforms physical window position to logical (unscrolled) position.
- Parameters:
ptPhysical (wx.Point)
- Return type:
Point
- GetMargins(self)¶
Returns the margins used by the control.
The
x
field of the returned point is the horizontal margin and they
field is the vertical one.- Return type:
Added 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.
- Return type:
int
- GetPhysicalPoint(self, ptLogical)¶
Transforms logical (unscrolled) position to physical window position.
- Parameters:
ptLogical (wx.Point)
- Return type:
Point
- GetPreDrag(self)¶
Are we trying to start Drag’n’Drop?
- Return type:
bool
- GetPropertiesMenuLabel(self, obj)¶
Gets the object’s properties menu label.
- Parameters:
- Return type:
str
- 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.
- Parameters:
from_ (long)
to_ (long)
- Return type:
str
- GetScale(self)¶
Returns an overall scale factor for displaying and editing the content.
- Return type:
float
- GetSelection(self)¶
- Return type:
- GetSelectionAnchor(self)¶
Returns an anchor so we know how to extend the selection.
It’s a caret position since it’s between two characters.
- Return type:
int
- GetSelectionAnchorObject(self)¶
Returns the anchor object if selecting multiple containers.
- Return type:
- 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)
- Return type:
- GetStringSelection(self)¶
Returns the text within the current selection range, if any.
- Return type:
str
- GetStyle(self, *args, **kw)¶
-
GetStyle (self, position, style)
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
.GetStyle (self, position, style)
- Parameters:
position (long)
style (wx.richtext.RichTextAttr)
- Return type:
bool
GetStyle (self, position, style, container)
- Parameters:
position (long)
style (wx.richtext.RichTextAttr)
container (wx.richtext.RichTextParagraphLayoutBox)
- Return type:
bool
- GetStyleForRange(self, *args, **kw)¶
-
GetStyleForRange (self, range, style)
Gets the attributes common to the specified range.
Attributes that differ in value within the range will not be included in style flags.
GetStyleForRange (self, range, style)
- Parameters:
range (wx.richtext.RichTextRange)
style (wx.richtext.RichTextAttr)
- Return type:
bool
GetStyleForRange (self, range, style, container)
- Parameters:
range (wx.richtext.RichTextRange)
style (wx.richtext.RichTextAttr)
container (wx.richtext.RichTextParagraphLayoutBox)
- Return type:
bool
- GetStyleSheet(self)¶
Returns the style sheet associated with the control, if any.
A style sheet allows named character and paragraph styles to be applied.
- Return type:
- GetTextCursor(self)¶
Returns the text (normal) cursor.
- Return type:
Cursor
- GetURLCursor(self)¶
Returns the cursor to be used over URLs.
- Return type:
Cursor
- GetUncombinedStyle(self, *args, **kw)¶
-
GetUncombinedStyle (self, position, style)
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.
GetUncombinedStyle (self, position, style, container)
- Parameters:
position (long)
style (wx.richtext.RichTextAttr)
container (wx.richtext.RichTextParagraphLayoutBox)
- Return type:
bool
- GetUnscaledRect(self, rect)¶
Returns an unscaled rectangle.
- Parameters:
rect (wx.Rect)
- Return type:
Rect
- GetValue(self)¶
Returns the content of the entire control as a string.
- Return type:
str
- GetVerticalScrollbarEnabled(self)¶
Returns
True
if the vertical scrollbar is enabled.- Return type:
bool
- GetVirtualAttributesEnabled(self)¶
Returns
True
if this control can use virtual attributes and virtual text.The default is
False
.- Return type:
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.
- Parameters:
caretPosition (long)
- Return type:
- 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.
- Parameters:
range (wx.richtext.RichTextRange)
style (wx.richtext.RichTextAttr)
- Return type:
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.
- Parameters:
range (wx.richtext.RichTextRange)
style (wx.richtext.RichTextAttr)
- Return type:
bool
- HasSelection(self)¶
Returns
True
if there is a selection and the object containing the selection was the same as the current focus object.- Return type:
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.- Return type:
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).
- Parameters:
pt (wx.Point)
- Return type:
le[wx.TextCtrlHitTestResult, int]
- HitTestXY(self, pt)¶
- Parameters:
pt (wx.Point)
- Return type:
le[wx.TextCtrlHitTestResult, TextCoord, TextCoord]
- Init(self)¶
Initialises the members of the control.
- Return type:
None
- Invalidate(self)¶
Invalidates the whole buffer to trigger painting later.
- Return type:
None
- 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.
- Return type:
bool
See also
- IsEditable(self)¶
Returns
True
if the control is editable.- Return type:
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.- Return type:
bool
Added in version 2.7.1.
- IsModified(self)¶
Returns
True
if the buffer has been modified.- Return type:
bool
- IsMultiLine(self)¶
Returns
True
if the control is multiline.- Return type:
bool
- IsPositionVisible(self, pos)¶
Returns
True
if the given position is visible on the screen.- Parameters:
pos (long)
- Return type:
bool
- IsSelectionAligned(self, alignment)¶
Returns
True
if all of the selection is aligned according to the specified flag.- Parameters:
alignment (TextAttrAlignment)
- Return type:
bool
- IsSelectionBold(self)¶
Returns
True
if all of the selection, or the content at the caret position, is bold.- Return type:
bool
- IsSelectionItalics(self)¶
Returns
True
if all of the selection, or the content at the caret position, is italic.- Return type:
bool
- IsSelectionUnderlined(self)¶
Returns
True
if all of the selection, or the content at the caret position, is underlined.- Return type:
bool
- IsSingleLine(self)¶
Returns
True
if the control is single-line.Currently wx.richtext.RichTextCtrl does not support single-line editing.
- Return type:
bool
Helper function implementing keyboard navigation.
- Parameters:
keyCode (int)
flags (int)
- Return type:
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.
- Parameters:
onlyVisibleRect (bool)
- Return type:
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.
- Return type:
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.
- Parameters:
file (string)
type (int)
- Return type:
bool
- MarkDirty(self)¶
Marks the buffer as modified.
- Return type:
None
- 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.- Parameters:
pos (long)
showAtLineStart (bool)
container (wx.richtext.RichTextParagraphLayoutBox)
- Return type:
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.
- Parameters:
oldPosition (long)
- Return type:
None
- 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.
- Parameters:
oldPosition (long)
- Return type:
None
- MoveDown(self, noLines=1, flags=0)¶
Moves the caret down.
- Parameters:
noLines (int)
flags (int)
- Return type:
bool
- MoveEnd(self, flags=0)¶
Moves to the end of the buffer.
- Parameters:
flags (int)
- Return type:
bool
- MoveHome(self, flags=0)¶
Moves to the start of the buffer.
- Parameters:
flags (int)
- Return type:
bool
- MoveLeft(self, noPositions=1, flags=0)¶
Moves left.
- Parameters:
noPositions (int)
flags (int)
- Return type:
bool
- MoveRight(self, noPositions=1, flags=0)¶
Moves right.
- Parameters:
noPositions (int)
flags (int)
- Return type:
bool
- MoveToLineEnd(self, flags=0)¶
Moves to the end of the line.
- Parameters:
flags (int)
- Return type:
bool
- MoveToLineStart(self, flags=0)¶
Moves to the start of the line.
- Parameters:
flags (int)
- Return type:
bool
- MoveToParagraphEnd(self, flags=0)¶
Moves to the end of the paragraph.
- Parameters:
flags (int)
- Return type:
bool
- MoveToParagraphStart(self, flags=0)¶
Moves to the start of the paragraph.
- Parameters:
flags (int)
- Return type:
bool
- MoveUp(self, noLines=1, flags=0)¶
Moves to the start of the paragraph.
- Parameters:
noLines (int)
flags (int)
- Return type:
bool
- Newline(self)¶
Inserts a new paragraph at the current insertion point.
- Return type:
bool
See also
- NumberList(self, *args, **kw)¶
-
NumberList (self, range, _def=None, flags=RICHTEXT_SETSTYLE_WITH_UNDO, startFrom=1, specifiedLevel=-1)
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.
- Parameters:
range (wx.richtext.RichTextRange)
flags (int)
startFrom (int)
specifiedLevel (int)
- Return type:
bool
See also
NumberList (self, range, defName, flags=RICHTEXT_SETSTYLE_WITH_UNDO, startFrom=1, specifiedLevel=-1)
- Parameters:
range (wx.richtext.RichTextRange)
defName (string)
flags (int)
startFrom (int)
specifiedLevel (int)
- Return type:
bool
- OnCaptureLost(self, event)¶
- Parameters:
event (wx.MouseCaptureLostEvent)
- Return type:
None
- OnChar(self, event)¶
- Parameters:
event (wx.KeyEvent)
- Return type:
None
- OnClear(self, event)¶
Standard handler for the
wx.ID_CLEAR
command.- Parameters:
event (wx.CommandEvent)
- Return type:
None
- OnContextMenu(self, event)¶
Shows a standard context menu with undo, redo, cut, copy, paste, clear, and select all commands.
- Parameters:
event (wx.ContextMenuEvent)
- Return type:
None
- OnCopy(self, event)¶
Standard handler for the
wx.ID_COPY
command.- Parameters:
event (wx.CommandEvent)
- Return type:
None
- OnCut(self, event)¶
Standard handler for the
wx.ID_CUT
command.- Parameters:
event (wx.CommandEvent)
- Return type:
None
- OnDropFiles(self, event)¶
Loads the first dropped file.
- Parameters:
event (wx.DropFilesEvent)
- Return type:
None
- OnEraseBackground(self, event)¶
- Parameters:
event (wx.EraseEvent)
- Return type:
None
- OnIdle(self, event)¶
- Parameters:
event (wx.IdleEvent)
- Return type:
None
- OnKillFocus(self, event)¶
- Parameters:
event (wx.FocusEvent)
- Return type:
None
- OnLeftClick(self, event)¶
- Parameters:
event (wx.MouseEvent)
- Return type:
None
- OnLeftDClick(self, event)¶
- Parameters:
event (wx.MouseEvent)
- Return type:
None
- OnLeftUp(self, event)¶
- Parameters:
event (wx.MouseEvent)
- Return type:
None
- OnMiddleClick(self, event)¶
- Parameters:
event (wx.MouseEvent)
- Return type:
None
- OnMoveMouse(self, event)¶
- Parameters:
event (wx.MouseEvent)
- Return type:
None
- OnPaint(self, event)¶
- Parameters:
event (wx.PaintEvent)
- Return type:
None
- OnPaste(self, event)¶
Standard handler for the
wx.ID_PASTE
command.- Parameters:
event (wx.CommandEvent)
- Return type:
None
- OnProperties(self, event)¶
Standard handler for property commands.
- Parameters:
event (wx.CommandEvent)
- Return type:
None
- OnRedo(self, event)¶
Standard handler for the
wx.ID_REDO
command.- Parameters:
event (wx.CommandEvent)
- Return type:
None
- OnRightClick(self, event)¶
- Parameters:
event (wx.MouseEvent)
- Return type:
None
- OnScroll(self, event)¶
- Parameters:
event (wx.ScrollWinEvent)
- Return type:
None
- OnSelectAll(self, event)¶
Standard handler for the
wx.ID_SELECTALL
command.- Parameters:
event (wx.CommandEvent)
- Return type:
None
- OnSetFocus(self, event)¶
- Parameters:
event (wx.FocusEvent)
- Return type:
None
- OnSize(self, event)¶
- Parameters:
event (wx.SizeEvent)
- Return type:
None
- OnSysColourChanged(self, event)¶
- Parameters:
event (wx.SysColourChangedEvent)
- Return type:
None
- OnTimer(self, event)¶
Respond to timer events.
- Parameters:
event (wx.TimerEvent)
- Return type:
None
- OnUndo(self, event)¶
Standard handler for the
wx.ID_UNDO
command.- Parameters:
event (wx.CommandEvent)
- Return type:
None
- OnUpdateClear(self, event)¶
Standard update handler for the
wx.ID_CLEAR
command.- Parameters:
event (wx.UpdateUIEvent)
- Return type:
None
- OnUpdateCopy(self, event)¶
Standard update handler for the
wx.ID_COPY
command.- Parameters:
event (wx.UpdateUIEvent)
- Return type:
None
- OnUpdateCut(self, event)¶
Standard update handler for the
wx.ID_CUT
command.- Parameters:
event (wx.UpdateUIEvent)
- Return type:
None
- OnUpdatePaste(self, event)¶
Standard update handler for the
wx.ID_PASTE
command.- Parameters:
event (wx.UpdateUIEvent)
- Return type:
None
- OnUpdateProperties(self, event)¶
Standard update handler for property commands.
- Parameters:
event (wx.UpdateUIEvent)
- Return type:
None
- OnUpdateRedo(self, event)¶
Standard update handler for the
wx.ID_REDO
command.- Parameters:
event (wx.UpdateUIEvent)
- Return type:
None
- OnUpdateSelectAll(self, event)¶
Standard update handler for the
wx.ID_SELECTALL
command.- Parameters:
event (wx.UpdateUIEvent)
- Return type:
None
- OnUpdateUndo(self, event)¶
Standard update handler for the
wx.ID_UNDO
command.- Parameters:
event (wx.UpdateUIEvent)
- Return type:
None
- PageDown(self, noPages=1, flags=0)¶
Moves one or more pages down.
- Parameters:
noPages (int)
flags (int)
- Return type:
bool
- PageUp(self, noPages=1, flags=0)¶
Moves one or more pages up.
- Parameters:
noPages (int)
flags (int)
- Return type:
bool
- PaintAboveContent(self, WXUNUSED)¶
Other user defined painting after everything else (i.e. all text) is painted.
- Parameters:
WXUNUSED (wx.DC)
- Return type:
None
Added in version 2.9.1.
- Paste(self)¶
Pastes content from the clipboard to the buffer.
- Return type:
None
- PopStyleSheet(self)¶
Pops the style sheet from top of stack.
- Return type:
- PositionCaret(self, container=None)¶
Internal function to position the visible caret according to the current caret position.
- Parameters:
container (wx.richtext.RichTextParagraphLayoutBox)
- Return type:
None
- PositionToXY(self, pos)¶
Converts a text position to zero-based column and line numbers.
- Parameters:
pos (long)
- Return type:
Tuple[bool, int, int]
- 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.
- Parameters:
container (wx.richtext.RichTextParagraphLayoutBox)
- Return type:
None
- 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.
- Parameters:
event (wx.KeyEvent)
flags (int)
- Return type:
bool
- ProcessDelayedImageLoading(self, *args, **kw)¶
-
ProcessDelayedImageLoading (self, refresh)
Do delayed image loading and garbage-collect other images.
- Parameters:
refresh (bool)
- Return type:
bool
ProcessDelayedImageLoading (self, screenRect, box, loadCount)
- Parameters:
screenRect (wx.Rect)
loadCount (int)
- Return type:
bool
- ProcessMouseMovement(self, container, obj, position, pos)¶
Processes mouse movement in order to change the cursor.
- Parameters:
container (wx.richtext.RichTextParagraphLayoutBox)
position (long)
pos (wx.Point)
- Return type:
bool
- PromoteList(self, *args, **kw)¶
-
PromoteList (self, promoteBy, range, _def=None, flags=RICHTEXT_SETSTYLE_WITH_UNDO, specifiedLevel=-1)
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.
- Parameters:
promoteBy (int)
range (wx.richtext.RichTextRange)
flags (int)
specifiedLevel (int)
- Return type:
bool
See also
See also
PromoteList (self, promoteBy, range, defName, flags=RICHTEXT_SETSTYLE_WITH_UNDO, specifiedLevel=-1)
- Parameters:
promoteBy (int)
range (wx.richtext.RichTextRange)
defName (string)
flags (int)
specifiedLevel (int)
- Return type:
bool
- PushStyleSheet(self, styleSheet)¶
Push the style sheet to top of stack.
- Parameters:
styleSheet (wx.richtext.RichTextStyleSheet)
- Return type:
bool
- Redo(self)¶
Redoes the current command.
- Return type:
None
- RefreshForSelectionChange(self, oldSelection, newSelection)¶
Refreshes the area affected by a selection change.
- Parameters:
oldSelection (wx.richtext.RichTextSelection)
newSelection (wx.richtext.RichTextSelection)
- Return type:
bool
- Remove(self, from_, to_)¶
Removes the content in the specified range.
- Parameters:
from_ (long)
to_ (long)
- Return type:
None
- Replace(self, from_, to_, value)¶
Replaces the content in the specified range with the string specified by value.
- Parameters:
from_ (long)
to_ (long)
value (string)
- Return type:
None
- RequestDelayedImageProcessing(self)¶
Request delayed image processing.
- Return type:
None
- 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.
- Parameters:
file (string)
type (int)
- Return type:
bool
- ScrollIntoView(self, position, keyCode)¶
Scrolls position into view.
This function takes a caret position.
- Parameters:
position (long)
keyCode (int)
- Return type:
bool
- SelectAll(self)¶
Selects all the text in the buffer.
- Return type:
None
- SelectNone(self)¶
Cancels any selection.
- Return type:
None
- SelectWord(self, position)¶
Selects the word at the given character position.
- Parameters:
position (long)
- Return type:
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.- Parameters:
attr (wx.richtext.RichTextAttr)
- Return type:
None
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).
- Parameters:
style (wx.richtext.RichTextAttr)
- Return type:
None
- 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.
- Parameters:
atStart (bool)
- Return type:
None
- 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.- Parameters:
position (long)
showAtLineStart (bool)
- Return type:
None
- SetCaretPositionAfterClick(self, container, position, hitTestFlags, extendSelection=False)¶
Sets up the caret for the given position and container, after a mouse click.
- Parameters:
container (wx.richtext.RichTextParagraphLayoutBox)
position (long)
hitTestFlags (int)
extendSelection (bool)
- Return type:
bool
- SetCaretPositionForDefaultStyle(self, pos)¶
Set the caret position for the default style that the user is selecting.
- Parameters:
pos (long)
- Return type:
None
- SetContextMenu(self, menu)¶
Sets the current context menu.
- Parameters:
menu (wx.Menu)
- Return type:
None
- SetDefaultStyle(self, *args, **kw)¶
-
SetDefaultStyle (self, style)
Sets the current default style, which can be used to change how subsequently inserted text is displayed.
- Parameters:
style (wx.TextAttr)
- Return type:
bool
SetDefaultStyle (self, style)
- Parameters:
style (wx.richtext.RichTextAttr)
- Return type:
bool
- SetDefaultStyleToCursorStyle(self)¶
Sets the default style to the style under the cursor.
- Return type:
bool
- SetDelayedImageProcessingRequired(self, b)¶
Sets the flag indicating that delayed image processing is required.
- Parameters:
b (bool)
- Return type:
None
- SetDelayedImageProcessingTime(self, t)¶
Sets the last time delayed image processing was performed.
- Parameters:
t (long)
- Return type:
None
- 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.
- Parameters:
threshold (long)
- Return type:
None
- 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.
- Parameters:
dimScale (float)
refresh (bool)
- Return type:
None
- SetDragStartPoint(self, sp)¶
Set the possible Drag’n’Drop start point.
- Parameters:
sp (wx.Point)
- Return type:
None
- SetDragStartTime(self, st)¶
Set the possible Drag’n’Drop start time.
- Parameters:
st (wx.DateTime)
- Return type:
None
- SetDragging(self, dragging)¶
Sets a flag to remember if we are extending a selection.
- Parameters:
dragging (bool)
- Return type:
None
- SetEditable(self, editable)¶
Makes the control editable, or not.
- Parameters:
editable (bool)
- Return type:
None
- SetFilename(self, filename)¶
Sets the current filename.
- Parameters:
filename (string)
- Return type:
None
- SetFocusObject(self, obj, setCaretPosition=True)¶
Sets the wx.richtext.RichTextObject object that currently has the editing focus.
- Parameters:
obj (wx.richtext.RichTextParagraphLayoutBox) – The wx.richtext.RichTextObject to set focus on.
setCaretPosition (bool) – Optionally set the caret position.
- Return type:
bool
- SetFont(self, font)¶
Sets the font, and also the basic and default attributes (see
wx.richtext.RichTextCtrl.SetDefaultStyle
).- Parameters:
font (wx.Font)
- Return type:
bool
- SetFontScale(self, fontScale, refresh=False)¶
Sets the scale factor for displaying fonts, for example for more comfortable editing.
- Parameters:
fontScale (float)
refresh (bool)
- Return type:
None
- SetFullLayoutRequired(self, b)¶
- Parameters:
b (bool)
- Return type:
None
- SetFullLayoutSavedPosition(self, p)¶
- Parameters:
p (long)
- Return type:
None
- SetFullLayoutTime(self, t)¶
- Parameters:
t (long)
- Return type:
None
- 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.
- Parameters:
flags (int)
- Return type:
None
- 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
orChangeValue
or others which use them internally (e.g.Clear
). In other words, currently you should avoid calling methods such asWriteText
orReplace
when using hints and the text control is empty. If you bind to the control’s focus and wxEVT_TEXT events, you must callwx.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.- Parameters:
hint (string)
- Return type:
bool
Added 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
).- Parameters:
pos (long)
- Return type:
None
- SetInsertionPointEnd(self)¶
Sets the insertion point to the end of the text control.
- Return type:
None
- 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)
- Parameters:
range (wx.richtext.RichTextRange)
- Return type:
None
- SetListStyle(self, *args, **kw)¶
-
SetListStyle (self, range, styleDef, flags=RICHTEXT_SETSTYLE_WITH_UNDO, startFrom=1, specifiedLevel=-1)
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.
- Parameters:
range (wx.richtext.RichTextRange)
styleDef (wx.richtext.RichTextListStyleDefinition)
flags (int)
startFrom (int)
specifiedLevel (int)
- Return type:
bool
See also
SetListStyle (self, range, defName, flags=RICHTEXT_SETSTYLE_WITH_UNDO, startFrom=1, specifiedLevel=-1)
- Parameters:
range (wx.richtext.RichTextRange)
defName (string)
flags (int)
startFrom (int)
specifiedLevel (int)
- Return type:
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.
- Returns:
True
if setting of all requested margins was successful.
Added in version 2.9.1.
SetMargins (self, pt)
- Parameters:
pt (wx.Point)
- Return type:
bool
SetMargins (self, left, top=-1)
- Parameters:
left (int)
top (int)
- Return type:
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.
- Parameters:
len (long)
- Return type:
None
- SetModified(self, modified)¶
- Parameters:
modified (bool)
- Return type:
None
- SetPreDrag(self, pd)¶
Set if we’re trying to start Drag’n’Drop.
- Parameters:
pd (bool)
- Return type:
None
- 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.
- Parameters:
range (wx.richtext.RichTextRange)
properties (wx.richtext.RichTextProperties)
flags (int)
- Return type:
bool
- SetScale(self, scale, refresh=False)¶
Sets an overall scale factor for displaying and editing the content.
- Parameters:
scale (float)
refresh (bool)
- Return type:
None
- SetSelection(self, *args, **kw)¶
-
SetSelection (self, from_, to_)
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).
- Parameters:
from_ (long)
to_ (long)
- Return type:
None
SetSelection (self, sel)
- Parameters:
- Return type:
None
- 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.
- Parameters:
anchor (long)
- Return type:
None
- SetSelectionAnchorObject(self, anchor)¶
Sets the anchor object if selecting multiple containers.
- Parameters:
anchor (wx.richtext.RichTextObject)
- Return type:
None
- 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).
- Parameters:
range (wx.richtext.RichTextRange)
- Return type:
None
- 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).
- Parameters:
start (long)
end (long)
style (wx.TextAttr)
- Return type:
bool
SetStyle (self, start, end, style)
- Parameters:
start (long)
end (long)
style (wx.richtext.RichTextAttr)
- Return type:
bool
SetStyle (self, range, style)
- Parameters:
range (wx.richtext.RichTextRange)
style (wx.TextAttr)
- Return type:
bool
SetStyle (self, range, style)
- Parameters:
range (wx.richtext.RichTextRange)
style (wx.richtext.RichTextAttr)
- Return type:
bool
SetStyle (self, obj, textAttr, flags=RICHTEXT_SETSTYLE_WITH_UNDO)
Sets the attributes for a single object.
- Parameters:
textAttr (wx.richtext.RichTextAttr)
flags (int)
- Return type:
None
- 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.
- Parameters:
range (wx.richtext.RichTextRange)
style (wx.richtext.RichTextAttr)
flags (int)
- Return type:
bool
- SetStyleSheet(self, styleSheet)¶
Sets the style sheet associated with the control.
A style sheet allows named character and paragraph styles to be applied.
- Parameters:
styleSheet (wx.richtext.RichTextStyleSheet)
- Return type:
None
- SetTextCursor(self, cursor)¶
Sets the text (normal) cursor.
- Parameters:
cursor (wx.Cursor)
- Return type:
None
- SetURLCursor(self, cursor)¶
Sets the cursor to be used over URLs.
- Parameters:
cursor (wx.Cursor)
- Return type:
None
- SetValue(self, value)¶
Replaces existing content with the given text.
- Parameters:
value (string)
- Return type:
None
- SetupScrollbars(self, atTop=False)¶
A helper function setting up scrollbars, for example after a resize.
- Parameters:
atTop (bool)
- Return type:
None
- ShouldInheritColours(self)¶
Return
True
from here to allow the colours of this window to be changed byInheritAttributes
.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 returnsTrue
.- Return type:
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.
- Parameters:
pos (long)
- Return type:
None
- StartCellSelection(self, table, newCell)¶
Starts selecting table cells.
- Parameters:
table (wx.richtext.RichTextTable)
newCell (wx.richtext.RichTextParagraphLayoutBox)
- Return type:
bool
- StoreFocusObject(self, obj)¶
Setter for m_focusObject.
- Parameters:
- Return type:
None
- SuppressingUndo(self)¶
Returns
True
if undo history suppression is on.- Return type:
bool
- Undo(self)¶
Undoes the command at the top of the command history, if there is one.
- Return type:
None
- WordLeft(self, noPages=1, flags=0)¶
Moves a number of words to the left.
- Parameters:
noPages (int)
flags (int)
- Return type:
bool
- WordRight(self, noPages=1, flags=0)¶
Move a number of words to the right.
- Parameters:
noPages (int)
flags (int)
- Return type:
bool
- WriteField(self, fieldType, properties, textAttr=RichTextAttr())¶
Writes a field at the current insertion point.
- Parameters:
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.
- Return type:
- 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.
- Parameters:
image (wx.Image)
bitmapType (BitmapType)
textAttr (wx.richtext.RichTextAttr)
- Return type:
bool
WriteImage (self, bitmap, bitmapType=BITMAP_TYPE_PNG, textAttr=RichTextAttr())
- Parameters:
bitmap (wx.Bitmap)
bitmapType (BitmapType)
textAttr (wx.richtext.RichTextAttr)
- Return type:
bool
WriteImage (self, filename, bitmapType, textAttr=RichTextAttr())
Loads an image from a file and writes it at the current insertion point.
- Parameters:
filename (string)
bitmapType (BitmapType)
textAttr (wx.richtext.RichTextAttr)
- Return type:
bool
WriteImage (self, imageBlock, textAttr=RichTextAttr())
Writes an image block at the current insertion point.
- Parameters:
imageBlock (wx.richtext.RichTextImageBlock)
textAttr (wx.richtext.RichTextAttr)
- Return type:
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.- Parameters:
rows (int)
cols (int)
tableAttr (wx.richtext.RichTextAttr)
cellAttr (wx.richtext.RichTextAttr)
- Return type:
- WriteText(self, text)¶
Writes text at the current position.
- Parameters:
text (string)
- Return type:
None
- 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.- Parameters:
textAttr (wx.richtext.RichTextAttr)
- Return type:
- XYToPosition(self, x, y)¶
Translates from column and line number to position.
- Parameters:
x (long)
y (long)
- Return type:
int
Properties¶
- BasicStyle¶
See
GetBasicStyle
andSetBasicStyle
- CaretAtLineStart¶
- CaretPosition¶
See
GetCaretPosition
andSetCaretPosition
- CaretPositionForDefaultStyle¶
See
GetCaretPositionForDefaultStyle
andSetCaretPositionForDefaultStyle
- CommandProcessor¶
- ContextMenu¶
See
GetContextMenu
andSetContextMenu
- ContextMenuPropertiesInfo¶
- DefaultStyle¶
See
GetDefaultStyle
andSetDefaultStyle
- DefaultStyleEx¶
- DelayedImageLoading¶
- DelayedImageProcessingRequired¶
See
GetDelayedImageProcessingRequired
andSetDelayedImageProcessingRequired
- DelayedImageProcessingTime¶
See
GetDelayedImageProcessingTime
andSetDelayedImageProcessingTime
- DelayedLayoutThreshold¶
- DimensionScale¶
See
GetDimensionScale
andSetDimensionScale
- DragStartPoint¶
See
GetDragStartPoint
andSetDragStartPoint
- DragStartTime¶
See
GetDragStartTime
andSetDragStartTime
- Dragging¶
See
GetDragging
andSetDragging
- Filename¶
See
GetFilename
andSetFilename
- FirstVisiblePoint¶
- FirstVisiblePosition¶
- FocusObject¶
See
GetFocusObject
andSetFocusObject
- FontScale¶
See
GetFontScale
andSetFontScale
- FullLayoutRequired¶
- FullLayoutSavedPosition¶
See
GetFullLayoutSavedPosition
andSetFullLayoutSavedPosition
- FullLayoutTime¶
See
GetFullLayoutTime
andSetFullLayoutTime
- HandlerFlags¶
See
GetHandlerFlags
andSetHandlerFlags
- ImagesEnabled¶
See
GetImagesEnabled
- InsertionPoint¶
See
GetInsertionPoint
andSetInsertionPoint
- InternalSelectionRange¶
- LastPosition¶
See
GetLastPosition
- Margins¶
See
GetMargins
andSetMargins
- NumberOfLines¶
See
GetNumberOfLines
- PreDrag¶
See
GetPreDrag
andSetPreDrag
- Selection¶
See
GetSelection
andSetSelection
- SelectionAnchor¶
See
GetSelectionAnchor
andSetSelectionAnchor
- SelectionAnchorObject¶
- SelectionRange¶
See
GetSelectionRange
andSetSelectionRange
- StringSelection¶
- StyleSheet¶
See
GetStyleSheet
andSetStyleSheet
- TextCursor¶
See
GetTextCursor
andSetTextCursor
- URLCursor¶
See
GetURLCursor
andSetURLCursor
- VerticalScrollbarEnabled¶
- VirtualAttributesEnabled¶