TTkTextEditView๐ŸŒถ๏ธ

class TTkTextEditView(*, readOnly: bool = False, multiLine: bool = True, document: TTkTextDocument = None, **kwargs)[source]๐ŸŒถ๏ธ

Bases: TTkAbstractScrollView

TTkTextEditView

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘ 0โ–Œ"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor โ•ฅ   โ•‘
โ•‘ <โ–Œincididunt ut labore et dolore magna aliqua.                                    โ•‘   โ•‘
โ•‘ 1โ–Œ                                                                                โ•‘   โ•‘
โ•‘ 2โ–ŒUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquโ•‘   โ•‘
โ•‘ <โ–Œip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate โ•‘   โ•‘
โ•‘ <โ–Œvelit esse cillum dolore eu fugiat nulla pariatur.                              โ•‘   โ•‘
โ•‘ 3โ–Œ                                                                                โ•‘   โ•‘
โ•‘ 4โ–ŒExcepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deseruโ•‘   โ•‘
โ•‘ <โ–Œnt mollit anim id est laborum."                                                 โ•จ   โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Demo: textedit.py (Try Online)

ttkdesigner Tutorial

Parameters:
  • lineNumber (bool, optional) โ€“ Show the line number on the left, defaults to False

  • readOnly (bool, optional) โ€“ In a read-only text edit the user can only navigate through the text and select text; modifying the text is not possible, defaults to True

  • multiLine (bool, optional) โ€“ In a multiline text edit the user can split the text in multiple lines, defaults to True

  • document (TTkTextDocument, optional) โ€“ If required an external Document can be used in this text editor, this option is useful if multiple editors share the same document as in the demo, defaults to a new Document

TTkContainerโ€™s inherited init params:

Parameters:
  • layout (TermTk.TTkLayouts) โ€“ the layout of this widget, optional, defaults to TTkLayout

  • padding (TTkPadding) โ€“ the padding (top, bottom, left, right) of the widget, defaults to (0,0,0,0)

  • paddingTop (int) โ€“ the Top padding, override Top padding if already defined, optional, default=0 if padding is not defined

  • paddingBottom (int) โ€“ the Bottom padding, override Bottom padding if already defined, optional, default=0 if padding is not defined

  • paddingLeft (int) โ€“ the Left padding, override Left padding if already defined, optional, default=0 if padding is not defined

  • paddingRight (int) โ€“ the Right padding, override Right padding if already defined, optional, default=0 if padding is not defined

  • forwardStyle (bool) โ€“ [Experimental] any change of style will reflect the children, defaults to False

TTkWidgetโ€™s inherited init params:

Parameters:
  • name (str, optional) โ€“ the name of the widget, defaults to โ€œโ€

  • parent (TTkWidget, optional) โ€“ the parent widget, defaults to None

  • x (int, optional) โ€“ the x position, defaults to 0

  • y (int, optional) โ€“ the y position, defaults to 0

  • pos ((int,int), optional) โ€“ the [x,y] position (override the previously defined x, y), defaults to (x,y)

  • width (int, optional) โ€“ the width of the widget, defaults to 0

  • height (int, optional) โ€“ the height of the widget, defaults to 0

  • size ((int,int), optional) โ€“ the size [width, height] of the widget (override the previously defined sizes), defaults to (width,height)

  • maxWidth (int, optional) โ€“ the maxWidth of the widget, defaults to 0x10000

  • maxHeight (int, optional) โ€“ the maxHeight of the widget, defaults to 0x10000

  • maxSize ((int,int), optional) โ€“ the max [width,height] of the widget, optional, defaults to (maxWidth,maxHeight)

  • minWidth (int, optional) โ€“ the minWidth of the widget, defaults to 0

  • minHeight (int, optional) โ€“ the minHeight of the widget, defaults to 0

  • minSize ((int,int), optional) โ€“ the minSize [width,height] of the widget, optional, defaults to (minWidth,minHeight)

  • toolTip (TTkString, optional) โ€“ This property holds the widgetโ€™s tooltip, defaults to โ€˜โ€™

  • style (dict, optional) โ€“ this field hold the custom style to be used by this widget

  • addStyle (dict, optional) โ€“ this field is required to override/merge the new style on top of the current one, useful if only few params need to be changed

  • visible (bool, optional) โ€“ the visibility, optional, defaults to True

  • enabled (bool, optional) โ€“ the ability to handle input events, optional, defaults to True

Style๐ŸŒถ๏ธ

classStyle = {
            'default':     {'color':         TTkColor.fg("#dddddd")+TTkColor.bg("#222222"),
                            'selectedColor': TTkColor.fg("#ffffff")+TTkColor.bg("#008844"),
                            'lineColor':     TTkColor.fg("#444444"),
                            'wrapLineColor': TTkColor.fg("#888888")+TTkColor.bg("#333333")},
            'disabled':    {'color': TTkColor.fg('#888888'),
                            'selectedColor': TTkColor.bg("#888888"),
                            'lineColor':     TTkColor.fg("#888888"),
                            'wrapLineColor': TTkColor.fg('#888888')},
            'focus':       {'selectedColor': TTkColor.fg("#ffffff")+TTkColor.bg("#008888")},
        }

Signals๐ŸŒถ๏ธ

closed

This signal is emitted whenever the widget is closed

currentColorChanged

This signal is emitted if the current character color has changed, for example caused by a change of the cursor position.

currentStyleChanged

This signal is emitted whenever the widget stye change

focusChanged

This signal is emitted whenever the focus status change i.e. with the setFocus() or clearFocus() methods.

redoAvailable

This signal is emitted whenever redo operations become available (available is true) or unavailable (available is false).

sizeChanged

This signal is emitted whenever the widget size change

textChanged

This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied.

undoAvailable

This signal is emitted whenever undo operations become available (available is true) or unavailable (available is false).

viewChanged

This signal is emitted whenever there is a change in the view content topology (size,pos)

viewMovedTo

This signal is emitted when the view content move to a new position (x,y),

viewSizeChanged

This signal is emitted when the view content size changed

Slots๐ŸŒถ๏ธ

append(text)

clear()

copy()

cut()

paste()

redo()

setColor(color)

setText(text)

undo()

Slots Inherited from: TTkAbstractScrollView

viewMoveTo(x,ย y)

This method is used to set the vertical and horizontal offsets of the TTkAbstractScrollViewInterface

Slots Inherited from: TTkContainer

hide()

hide the widget

show()

show the widget

Slots Inherited from: TTkWidget

close()

Close (Destroy/Remove) the widget

hide()

hide the widget

lowerWidget()

Lower the Widget below its relatives

raiseWidget([raiseParent])

Raise the Widget above its relatives

setDisabled([disabled])

This property holds whether the widget is disnabled

setEnabled([enabled])

This property holds whether the widget is enabled

setFocus()

Focus the widget

setVisible(visible)

Set the visibility status of this widget

show()

show the widget

update([repaint,ย updateLayout,ย updateParent])

Notify the drawing routine that the widget changed and needs to draw its new content.

Members๐ŸŒถ๏ธ

closed: pyTTkSignal๐ŸŒถ๏ธ

This signal is emitted whenever the widget is closed

Parameters:

widget (TTkWidget) โ€“ the widget closed (=self)

currentColorChanged: pyTTkSignal๐ŸŒถ๏ธ

This signal is emitted if the current character color has changed, for example caused by a change of the cursor position.

Parameters:

color (TTkColor) โ€“ the new color

currentStyleChanged: pyTTkSignal๐ŸŒถ๏ธ

This signal is emitted whenever the widget stye change

Parameters:

style (dict) โ€“ the new style applied

focusChanged: pyTTkSignal๐ŸŒถ๏ธ

This signal is emitted whenever the focus status change i.e. with the setFocus() or clearFocus() methods

Parameters:

status (bool) โ€“ the curent focus status

redoAvailable: pyTTkSignal๐ŸŒถ๏ธ

This signal is emitted whenever redo operations become available (available is true) or unavailable (available is false).

Parameters:

available (bool) โ€“ the availability of redo

sizeChanged: pyTTkSignal๐ŸŒถ๏ธ

This signal is emitted whenever the widget size change

Parameters:
  • width (int) โ€“ the new widget width

  • height (int) โ€“ the new widget height

textChanged: pyTTkSignal๐ŸŒถ๏ธ

This signal is emitted whenever the documentโ€™s content changes; for example, when text is inserted or deleted, or when formatting is applied.

undoAvailable: pyTTkSignal๐ŸŒถ๏ธ

This signal is emitted whenever undo operations become available (available is true) or unavailable (available is false).

Parameters:

available (bool) โ€“ the availability of undo

viewChanged: pyTTkSignal๐ŸŒถ๏ธ

This signal is emitted whenever there is a change in the view content topology (size,pos)

Note

This signal must be implemented in any implementation of TTkAbstractScrollView to notify that the view content boudaries changed

viewMovedTo: pyTTkSignal๐ŸŒถ๏ธ

This signal is emitted when the view content move to a new position (x,y),

Parameters:
  • x (int) โ€“ the new horizontal offset

  • y (int) โ€“ the new vertical offset

viewSizeChanged: pyTTkSignal๐ŸŒถ๏ธ

This signal is emitted when the view content size changed

Parameters:
  • width (int) โ€“ the new width

  • height (int) โ€“ the new heighht

Methods๐ŸŒถ๏ธ

append(text)[source]๐ŸŒถ๏ธ
clear()[source]๐ŸŒถ๏ธ
copy()[source]๐ŸŒถ๏ธ
cut()[source]๐ŸŒถ๏ธ
document() TTkTextDocument[source]๐ŸŒถ๏ธ
isReadOnly() bool[source]๐ŸŒถ๏ธ
isRedoAvailable()[source]๐ŸŒถ๏ธ
isUndoAvailable()[source]๐ŸŒถ๏ธ
lineWrapMode()[source]๐ŸŒถ๏ธ
multiLine() bool[source]๐ŸŒถ๏ธ

multiline

paste()[source]๐ŸŒถ๏ธ
redo()[source]๐ŸŒถ๏ธ
setColor(color)[source]๐ŸŒถ๏ธ
setDocument(document: TTkTextDocument)[source]๐ŸŒถ๏ธ
setLineWrapMode(mode)[source]๐ŸŒถ๏ธ
setReadOnly(ro)[source]๐ŸŒถ๏ธ
setText(text)[source]๐ŸŒถ๏ธ
setWordWrapMode(*args, **kwargs) None[source]๐ŸŒถ๏ธ
setWrapWidth(*args, **kwargs) None[source]๐ŸŒถ๏ธ
textCursor() TTkTextCursor[source]๐ŸŒถ๏ธ
toAnsi()[source]๐ŸŒถ๏ธ
toPlainText()[source]๐ŸŒถ๏ธ
toRawText()[source]๐ŸŒถ๏ธ
undo()[source]๐ŸŒถ๏ธ
viewFullAreaSize() -> (<class 'int'>, <class 'int'>)[source]๐ŸŒถ๏ธ

This method returns the full widget area size of the TTkAbstractScrollViewInterface implementation.

This is required to TTkAbstractScrollArea implementation to handle the on-demand scroll bars.

Note

Reimplement this function to handle this event

Returns:

the full area size as a tuple of 2 int elements (width,height)

Return type:

tuple[int,int]

wordWrapMode(*args, **kwargs) None[source]๐ŸŒถ๏ธ
wrapWidth(*args, **kwargs) None[source]๐ŸŒถ๏ธ

Methods Inherited from: TTkAbstractScrollView

getViewOffsets()

Retrieve the vertical and horizontal offsets of the TTkAbstractScrollViewInterface

resizeEvent(w,ย h)

Convenience function, Event Callback triggered after a successful resize

update([repaint,ย updateLayout,ย updateParent])

Notify the drawing routine that the widget changed and needs to draw its new content.

viewDisplayedSize()

This method returns the displayed size of the TTkAbstractScrollViewInterface implementation.

viewMoveTo(x,ย y)

This method is used to set the vertical and horizontal offsets of the TTkAbstractScrollViewInterface

wheelEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse wheel events for the widget.

Methods Inherited from: TTkContainer

addWidget(widget)

getPadding()

Retrieve the TTkContainer's paddings sizes as shown in Layout Topology

getWidgetByName(name)

Return the widget from its name.

hide()

hide the widget

layout()

Get the Layout

maximumHeight()

maximumWidth()

minimumHeight()

minimumWidth()

mouseEvent(evt)

paintChildCanvas()

removeWidget(widget)

rootLayout()

This is a root layout mainly used to place items that are not supposed to be inside the main layout (i.e. the menu elements).

setCurrentStyle(*args,ย **kwargs)

setLayout(layout)

Set the Layout used by this widget to place all the child widgets.

setPadding(top,ย bottom,ย left,ย right)

Set the TTkContainer's paddings sizes as shown in Layout Topology

show()

show the widget

update([repaint,ย updateLayout,ย updateParent])

Notify the drawing routine that the widget changed and needs to draw its new content.

Methods Inherited from: TTkWidget

clearFocus()

Remove the Focus state of this widget

close()

Close (Destroy/Remove) the widget

currentStyle()

disableWidgetCursor([disable])

enableWidgetCursor([enable])

focusInEvent()

focusOutEvent()

focusPolicy()

geometry()

getCanvas()

getPixmap()

Convenience function which return a pixmap representing the current widget status

getWidgetByName(name)

Return the widget from its name.

hasFocus()

This property holds the focus status of this widget

height()

hide()

hide the widget

isEnabled()

This property holds whether the widget is enabled

isEntered()

isVisible()

Retrieve the visibility status of this widget

isVisibleAndParent()

lowerWidget()

Lower the Widget below its relatives

maxDimension(orientation)

maximumHeight()

maximumSize()

maximumWidth()

mergeStyle(style)

minDimension(orientation)

minimumHeight()

minimumSize()

minimumWidth()

mouseEvent(evt)

move(x,ย y)

Move the widget

moveEvent(x,ย y)

Convenience function, Event Callback triggered after a successful move

name()

paintChildCanvas()

paintEvent(canvas)

Paint Event callback, this need to be overridden in the widget.

parentWidget()

pasteEvent(txt)

Callback triggered when a paste event is forwarded to this widget.

pos()

raiseWidget([raiseParent])

Raise the Widget above its relatives

resize(width,ย height)

Resize the widget

resizeEvent(w,ย h)

Convenience function, Event Callback triggered after a successful resize

setCurrentStyle(*args,ย **kwargs)

setDefaultSize(arg,ย width,ย height)

setDisabled([disabled])

This property holds whether the widget is disnabled

setEnabled([enabled])

This property holds whether the widget is enabled

setFocus()

Focus the widget

setFocusPolicy(policy)

This property holds the way the widget accepts keyboard focus

setGeometry(x,ย y,ย width,ย height)

Resize and move the widget

setMaximumHeight(maxh)

setMaximumSize(maxw,ย maxh)

setMaximumWidth(maxw)

setMinimumHeight(minh)

setMinimumSize(minw,ย minh)

setMinimumWidth(minw)

setName(name)

Set the name of this Instance

setParent(parent)

setStyle([style])

setToolTip(toolTip)

setVisible(visible)

Set the visibility status of this widget

setWidgetCursor([pos,ย type])

show()

show the widget

size()

style()

toolTip()

update([repaint,ย updateLayout,ย updateParent])

Notify the drawing routine that the widget changed and needs to draw its new content.

widgetItem()

width()

x()

y()

Methods Inherited from: TMouseEvents

enterEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse enter events for the widget.

leaveEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse leave events for the widget.

mouseDoubleClickEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse click events for the widget.

mouseDragEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse drag events for the widget.

mouseMoveEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse move events for the widget.

mousePressEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse press events for the widget.

mouseReleaseEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse release events for the widget.

mouseTapEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse click events for the widget.

wheelEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse wheel events for the widget.

Methods Inherited from: TKeyEvents

keyEvent(evt)

This event handler, can be reimplemented in a subclass to receive key events for the widget.

Methods Inherited from: TDragEvents

dragEnterEvent(evt)

This event handler, can be reimplemented in a subclass to receive drag events for the widget.

dragLeaveEvent(evt)

This event handler, can be reimplemented in a subclass to receive drag events for the widget.

dragMoveEvent(evt)

This event handler, can be reimplemented in a subclass to receive drag events for the widget.

dropEvent(evt)

This event handler, can be reimplemented in a subclass to receive drag events for the widget.

TTkTextEditView Attributes๐ŸŒถ๏ธ

classStyle