textctrlwrapper

Classes:

TextCtrlWrapper()

Base class for wrappers around wx.TextCtrl.

class TextCtrlWrapper[source]

Bases: object

Base class for wrappers around wx.TextCtrl.

Subclasses must set the value of textctrl.

Methods:

AppendText(text)

Appends the given text to the end of the text control.

CanCopy()

Returns True if the selection can be copied to the clipboard.

CanCut()

Returns True if the selection can be cut to the clipboard.

CanPaste()

Returns True if the contents of the clipboard can be pasted into the text control.

CanRedo()

Returns True if there is a redo facility available, and the last operation can be redone.

CanUndo()

Returns True if there is an undo facility available, and the last operation can be undone.

Clear()

Clears the text in the control.

Copy()

Copies the selected text to the clipboard.

Cut()

Copies the selected text to the clipboard and removes it from the control.

GetLastPosition()

Returns the zero based index of the last position in the text control, which is equal to the number of characters in the control.

GetSelection()

Gets the current selection span.

GetStringSelection()

Returns the text currently selected in the control.

GetValue()

Gets the contents of the control.

IsEditable()

Returns True if the controls contents may be edited by user (note that it always can be changed by the program).

IsEmpty()

Returns whether the control is currently empty.

Paste()

Pastes the clipboard contents into the control.

Redo()

If there is a redo facility and the last operation can be redone, redoes the last operation.

Remove(from_, to_)

Removes the text starting at the first given position up to (but not including) the character at the last position.

Replace(from_, to_, value)

Replaces the text starting at the first position up to (but not including) the character at the last position with the given text.

SelectAll()

Selects all text in the control.

SelectNone()

Deselects selected text in the control.

SetSelection(from_, to_)

Selects the text starting at the first position up to (but not including) the character at the last position.

SetValue(value)

Sets the new text control value.

Undo()

If there is an undo facility, and the last operation can be undone, undoes the last operation.

WriteText(text)

Writes the text into the text control at the current insertion position.

Attributes:

textctrl

The wx.TextCtrl being wrapped.

AppendText(text)[source]

Appends the given text to the end of the text control.

Note

After the text is appended, the insertion point will be at the end of the text control. If this behaviour is not desired, the programmer should use GetInsertionPoint and SetInsertionPoint.

Parameters

text (str)

CanCopy()[source]

Returns True if the selection can be copied to the clipboard.

Return type

bool

CanCut()[source]

Returns True if the selection can be cut to the clipboard.

Return type

bool

CanPaste()[source]

Returns True if the contents of the clipboard can be pasted into the text control.

On some platforms (Motif, GTK) this is an approximation and returns True if the control is editable, False otherwise.

Return type

bool

CanRedo()[source]

Returns True if there is a redo facility available, and the last operation can be redone.

Return type

bool

CanUndo()[source]

Returns True if there is an undo facility available, and the last operation can be undone.

Return type

bool

Clear()[source]

Clears the text in the control.

Note that this function will generate a wx.wxEVT_TEXT event, i.e. its effect is identical to calling SetValue('').

Copy()[source]

Copies the selected text to the clipboard.

Cut()[source]

Copies the selected text to the clipboard and removes it from the control.

GetLastPosition()[source]

Returns the zero based index of the last position in the text control, which is equal to the number of characters in the control.

Return type

wx.TextPos

GetSelection()[source]

Gets the current selection span.

If the returned values are equal, there was no selection.

Note

The indices returned may be used with the other wx.TextCtrl methods but don’t necessarily represent the correct indices into the string returned by GetValue for multiline controls under Windows (at least,) you should use GetStringSelection to get the selected text.

Return type

Tuple[int, int]

GetStringSelection()[source]

Returns the text currently selected in the control.

If there is no selection, the returned string is empty.

Return type

str

GetValue()[source]

Gets the contents of the control.

Note

For a multiline text control, the lines will be separated by (Unix-style) \n characters, even under Windows where they are separated by a \r\n sequence in the native control.

Return type

str

IsEditable()[source]

Returns True if the controls contents may be edited by user (note that it always can be changed by the program).

In other words, this functions returns True if the control hasn’t been put in read-only mode by a previous call to SetEditable().

Return type

bool

IsEmpty()[source]

Returns whether the control is currently empty.

Return type

bool

Paste()[source]

Pastes the clipboard contents into the control.

Redo()[source]

If there is a redo facility and the last operation can be redone, redoes the last operation.

Does nothing if there is no redo facility.

Remove(from_, to_)[source]

Removes the text starting at the first given position up to (but not including) the character at the last position.

This function puts the current insertion point position at to as a side effect.

Parameters
  • from_ (int) – The first position

  • to_ (int) – The last position

Replace(from_, to_, value)[source]

Replaces the text starting at the first position up to (but not including) the character at the last position with the given text.

This function puts the current insertion point position at to as a side effect.

Parameters
  • from_ (int) – The first position

  • to_ (int) – The last position

  • value – The value to replace the existing text with.

Return type

str

SelectAll()[source]

Selects all text in the control.

SelectNone()[source]

Deselects selected text in the control.

SetSelection(from_, to_)[source]

Selects the text starting at the first position up to (but not including) the character at the last position.

If both parameters are equal to -1 all text in the control is selected.

Notice that the insertion point will be moved to from by this function.

Parameters
  • from_ (int) – The first position

  • to_ (int) – The last position

SetValue(value)[source]

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 SetValue().

The insertion point is set to the start of the control (i.e. position 0) by this function unless the control value doesn’t change at all, in which case the insertion point is left at its original position.

Note

Unlike most other functions changing the control’s values, this function generates a wx.wxEVT_TEXT event. To avoid this you can use ChangeValue() instead.

Parameters

value (str) – The new value to set. It may contain newline characters if the text control is multiline.

Undo()[source]

If there is an undo facility, and the last operation can be undone, undoes the last operation.

Does nothing if there is no undo facility.

WriteText(text)[source]

Writes the text into the text control at the current insertion position.

Parameters

text (str) – Text to write to the text control

textctrl

Type:    TextCtrl

The wx.TextCtrl being wrapped.