gtk.TextView
Prev | The gtk Class Reference | Next

## gtk.TextView

gtk.TextView — a widget that displays the contents of a `gtk.TextBuffer`

## Synopsis

    class gtk.TextView(gtk.Container):
        gtk.TextView(buffer=None)
        def set_buffer(buffer)
        def get_buffer()
        def scroll_to_iter(iter, within_margin, use_align=False, xalign=0.5, yalign=0.5)
        def scroll_to_mark(mark, within_margin, use_align=False, xalign=0.5, yalign=0.5)
        def scroll_mark_onscreen(mark)
        def move_mark_onscreen(mark)
        def place_cursor_onscreen()
        def get_visible_rect()
        def set_cursor_visible(setting)
        def get_cursor_visible()
        def get_iter_location(iter)
        def get_iter_at_location(x, y)
        def get_line_yrange(iter)
        def get_line_at_y(target_iter)
        def buffer_to_window_coords(win, buffer_x, buffer_y)
        def window_to_buffer_coords(win, window_x, window_y)
        def get_window(win)
        def get_window_type(window)
        def set_border_window_size(type, size)
        def get_border_window_size(type)
        def forward_display_line(iter)
        def backward_display_line(iter)
        def forward_display_line_end(iter)
        def backward_display_line_start(iter)
        def starts_display_line(iter)
        def move_visually(iter, count)
        def add_child_at_anchor(child, anchor)
        def add_child_in_window(child, which_window, xpos, ypos)
        def move_child(child, xpos, ypos)
        def set_wrap_mode(wrap_mode)
        def get_wrap_mode()
        def set_editable(setting)
        def get_editable()
        def set_overwrite(overwrite)
        def get_overwrite()
        def set_accepts_tab(accepts_tab)
        def get_accepts_tab()
        def set_pixels_above_lines(pixels_above_lines)
        def get_pixels_above_lines()
        def set_pixels_below_lines(pixels_below_lines)
        def get_pixels_below_lines()
        def set_pixels_inside_wrap(pixels_inside_wrap)
        def get_pixels_inside_wrap()
        def set_justification(justification)
        def get_justification()
        def set_left_margin(left_margin)
        def get_left_margin()
        def set_right_margin(right_margin)
        def get_right_margin()
        def set_indent(indent)
        def get_indent()
        def set_tabs(tabs)
        def get_tabs()
        def get_default_attributes()
        def get_hadjustment()
        def get_vadjustment()

## Ancestry

    +-- gobject.GObject
      +-- gtk.Object
        +-- gtk.Widget
          +-- gtk.Container
            +-- gtk.TextView

## Implemented Interfaces

`gtk.TextView` implements `gtk.Buildable`

## gtk.TextView Properties

gtk.Object Properties

gtk.Widget Properties

gtk.Container Properties

"accepts-tab" | Read-Write | If `True`, pressing Tab will result in a tab character being entered; otherwise the focus will be moved. Available in GTK+ 2.4 and above.
"buffer" | Read-Write | The buffer that is displayed. Available in GTK+ 2.4 and above.
"cursor-visible" | Read-Write | If `True`, the insertion cursor is shown
"editable" | Read-Write | If `True`, the text can be modified by the user by default
"indent" | Read-Write | The default amount to indent the paragraph, in pixels
"justification" | Read-Write | The default text justification: `gtk.JUSTIFY_LEFT`, `gtk.JUSTIFY_RIGHT`, `gtk.JUSTIFY_CENTER` or `gtk.JUSTIFY_FILL`
"left-margin" | Read-Write | The default width of the left margin in pixels
"overwrite" | Read-Write | If `True`, the entered text overwrites existing contents. Available in GTK+ 2.4 and above.
"pixels-above-lines" | Read-Write | The default number of pixels of blank space above paragraphs
"pixels-below-lines" | Read-Write | The default number of pixels of blank space below paragraphs
"pixels-inside-wrap" | Read-Write | The default number of pixels of blank space between wrapped lines in a paragraph
"right-margin" | Read-Write | The default width of the right margin in pixels
"tabs" | Read-Write | The default custom tabs
"wrap-mode" | Read-Write | The default wrap mode: `gtk.WRAP_NONE`, `gtk.WRAP_CHAR` or `gtk.WRAP_WORD`

## gtk.TextView Style Properties

gtk.Widget Style Properties

"error-underline-color" | Read-Write | The `gtk.gdk.Color` with which to draw error-indication underlines. Available in GTK+ 2.4 and above.

## gtk.TextView Signal Prototypes

gobject.GObject Signal Prototypes

gtk.Object Signal Prototypes

gtk.Widget Signal Prototypes

gtk.Container Signal Prototypes

"backspace | `def callback(`textview`, `user_param1`, `...`)`
"copy-clipboard" | `def callback(`textview`, `user_param1`, `...`)`
"cut-clipboard" | `def callback(`textview`, `user_param1`, `...`)`
"delete-from-cursor" | `def callback(`textview`, `delete_type`, `count`, `user_param1`, `...`)`
"insert-at-cursor" | `def callback(`textview`, `string`, `user_param1`, `...`)`
"move-cursor" | `def callback(`textview`, `step_size`, `count`, `extend_selection`, `user_param1`, `...`)`
"move-focus" | `def callback(`textview`, `direction`, `user_param1`, `...`)`
"move-viewport" | `def callback(`textview`, `scrollstep`, `count`, `user_param1`, `...`)`
"page-horizontally" | `def callback(`textview`, `count`, `extend_selection`, `user_param1`, `...`)`
"paste-clipboard" | `def callback(`textview`, `user_param1`, `...`)`
"populate-popup" | `def callback(`textview`, `menu`, `user_param1`, `...`)`
"select-all" | `def callback(`textview`, `select`, `user_param1`, `...`)`
"set-anchor" | `def callback(`textview`, `user_param1`, `...`)`
"set-scroll-adjustments" | `def callback(`textview`, `hadjustment`, `vadjustment`, `user_param1`, `...`)`
"toggle-overwrite" | `def callback(`textview`, `user_param1`, `...`)`

## Description

A `gtk.TextView` widget provides the display for the contents of a `gtk.TextBuffer` object. A textview provides a set of attributes for the default display of text from a textbuffer. The attributes set by `gtk.TextTag` objects override the attributes set on a `gtk.TextView` widget. Since a `gtk.TextBuffer` can be associated with multiple `gtk.TextView` widgets each having a different set of default attributes, the display of the same text in different textview widgets can be quite different except for those attributes that are overridden by texttags.

A `gtk.TextView` widget has several `gtk.gdk.Window` widgets most of which are not displayed by default:

`gtk.TEXT_WINDOW_WIDGET` | The widget window
`gtk.TEXT_WINDOW_TEXT` | The window that holds the text
`gtk.TEXT_WINDOW_LEFT` | The left border window - not displayed by default
`gtk.TEXT_WINDOW_RIGHT` | The right border window - not displayed by default
`gtk.TEXT_WINDOW_TOP` | The top border window - not displayed by default
`gtk.TEXT_WINDOW_BOTTOM` | The bottom border window - not displayed by default
`gtk.TEXT_WINDOW_PRIVATE` | An internal inaccessible `gtk.gdk.Window`

The border windows are not created until they are given a size by using the `set_border_window_size`() method.

Depending on the wrap mode of the textview a textbuffer line may be displayed as more than one screen display line. The textview has methods to navigate through the display lines.

A `gtk.TextChildAnchor` in a `gtk.TextBuffer` provides a place for a `PyGTK` widget to be placed in a `gtk.TextView`. Each textview displaying the same textbuffer with a child anchor must have a different widget placed at that child anchor. In addition, a widget can be placed at a specific location in one of the above `gtk.TextView` windows using the `add_child_in_window`() method. The widget will be clipped to the window boundaries if it is larger than the window or located where it extends beyond the window boundaries.

A `gtk.TextView` has a default popup menu that includes the usual cut, copy and paste capabilities. In PyGTK 2.2 `gtk.Clipboard` objects are supported so your program can access the contents of the cut, copy and paste clipboard through the `gdk.SELECTION_CLIPBOARD` clipboard. Also the selected text in a `gtk.TextView` is available on the `gdk.SELECTION_PRIMARY` clipboard.

## Constructor

        gtk.TextView(buffer=None)

`buffer` : | a `gtk.TextBuffer` or `None`
Returns : | a new `gtk.TextView`.

Creates a new `gtk.TextView` widget displaying the `gtk.TextBuffer` specified by `buffer`. If `buffer` is `None`, a new `gtk.TextBuffer` will be created. One textbuffer can be shared among many widgets.

## Methods

### gtk.TextView.set_buffer

        def set_buffer(buffer)

`buffer` : | a `gtk.TextBuffer`

The `set_buffer`() method sets the `gtk.TextBuffer` specified by `buffer` as the textbuffer being displayed by the textview.

### gtk.TextView.get_buffer

        def get_buffer()

Returns : | a `gtk.TextBuffer`

The `get_buffer`() method returns the `gtk.TextBuffer` being displayed by this textview.

### gtk.TextView.scroll_to_iter

        def scroll_to_iter(iter, within_margin, use_align=False, xalign=0.5, yalign=0.5)

`iter` : | a `gtk.TextIter` object
`within_margin` : | the margin as a [0.0,0.5) fraction of screen size
`use_align` : | if `True` use the alignment arguments; if `False`, just get `iter` on screen
`xalign` : | the horizontal alignment of `iter` within visible area.
`yalign` : | the vertical alignment of `iter` within visible area
Returns : | `True` if scrolling occurred

The `scroll_to_iter`() method scrolls the textview so that the `gtk.TextIter` location specified by `iter` is on the screen in the position indicated by `xalign` and `yalign`. If `use_align` is `True` the alignments specify the fraction of screen space to the left of or above the location of `iter`. If `use_align` is `False`, the text scrolls the minimal distance to get `iter` on screen, possibly not scrolling at all. The effective screen for purposes of this method is reduced by a margin of size specified by `within_margin`.

### Note

This method uses the currently-computed height of the lines in the text buffer. The line heights are computed in an idle handler so this method may not have the desired effect if it's called before the height computations are complete. To avoid oddness, consider using the `scroll_to_mark`() method that saves a point to be scrolled to after line validation.

### gtk.TextView.scroll_to_mark

        def scroll_to_mark(mark, within_margin, use_align=False, xalign=0.5, yalign=0.5)

`mark` : | a `gtk.TextMark` object
`within_margin` : | the margin as a [0.0,0.5) fraction of screen size
`use_align` : | if `True` use the alignment arguments; if `False`, just get `mark` on screen
`xalign` : | the horizontal alignment of `mark` within the visible area.
`yalign` : | the vertical alignment of `mark` within the visible area

The `scroll_to_mark`() method scrolls the textview so that the `gtk.TextMark` location specified by `mark` is on the screen in the position specified by `xalign` and `yalign`. If `use_align` is `True` the alignments specify the fraction of screen space to the left of or above the location of `mark`. If `use_align` is `False`, the text scrolls the minimal distance to get `mark` on screen, possibly not scrolling at all. The effective screen for purposes of this function is reduced by a margin of size specified by `within_margin`.

### gtk.TextView.scroll_mark_onscreen

        def scroll_mark_onscreen(mark)

`mark` : | a `gtk.TextMark` in the textbuffer for textview

The `scroll_mark_onscreen`() method scrolls the textview the minimum distance to place the `gtk.TextMark` location specified by `mark` within the visible area of the widget.

### gtk.TextView.move_mark_onscreen

        def move_mark_onscreen(mark)

`mark` : | a `gtk.TextMark` object
Returns : | `True` if `mark` moved (wasn't already on screen)

The `move_mark_onscreen`() moves the `gtk.TextMark` location specified by `mark` to a location within the currently-visible text area of the textview.

### gtk.TextView.place_cursor_onscreen

        def place_cursor_onscreen()

Returns : | True if the cursor had to be moved.

The `place_cursor_onscreen`() method moves the cursor to a new location within the currently visible region of the buffer, if it isn't there already.

### gtk.TextView.get_visible_rect

        def get_visible_rect()

Returns : | a `gtk.gdk.Rectangle`

The `get_visible_rect`() method returns a `gtk.gdk.Rectangle` containing the coordinates of the currently-visible region of the buffer. The rectangle is in buffer coordinates that can be converted to window coordinates with the `buffer_to_window_coords`() method.

### gtk.TextView.set_cursor_visible

        def set_cursor_visible(setting)

`setting` : | if `True` show the insertion cursor

The `set_cursor_visible`() method sets the "cursor-visible" property to the value of `setting`. If `setting` is `True` the cursor is visible; if `False`, it is not. A buffer with no editable text probably shouldn't have a visible cursor, so you may want to turn the cursor off.

### gtk.TextView.get_cursor_visible

        def get_cursor_visible()

Returns : | `True` if the insertion mark is visible

The `get_cursor_visible`() method returns the value of the "cursor-visible" property that determines if the insertion point is visible.

### gtk.TextView.get_iter_location

        def get_iter_location(iter)

`iter` : | a `gtk.TextIter`
Returns : | a `gtk.gdk.Rectangle` containing the bounds of the character at `iter`

The `get_iter_location`() method returns a `gtk.gdk.Rectangle` that contains the character at the location specified by `iter`. The rectangle position is in buffer coordinates that can be converted to window coordinates with the `buffer_to_window_coords`() method.

### gtk.TextView.get_iter_at_location

        def get_iter_at_location(x, y)

`x` : | x position, in buffer coordinates
`y` : | y position, in buffer coordinates
Returns : | a `gtk.TextIter`

The `get_iter_at_location`() method returns a `gtk.TextIter` that points at the location specified by the buffer coordinates `x` and `y`. Buffer coordinates are coordinates for the entire buffer, not just the currently-displayed portion. Window coordinates from an event, must be converted to buffer coordinates with the `window_to_buffer_coords`() method before using them with this method.

### gtk.TextView.get_line_yrange

        def get_line_yrange(iter)

`iter` : | a `gtk.TextIter`
Returns : | a tuple containing a y coordinate and a height

The `get_line_yrange`() method locates the line containing the `gtk.TextIter` specified by `iter` and returns a tuple containing the y coordinate of the top of the line and the height of the line. The coordinate is a buffer coordinate that can be converted to window coordinates with the `buffer_to_window_coords`() method.

### gtk.TextView.get_line_at_y

        def get_line_at_y(y)

`y` : | a y coordinate
Returns : | a tuple containing a `gtk.TextIter` pointing at the line start and the top coordinate of the line

The `get_line_at_y`() method returns a tuple containing:

- a `gtk.TextIter` pointing at the start of the line with the vertical coordinate specified by `y` and,
- the vertical coordinate of the top edge of the line.

`y` is in buffer coordinates that can be converted from window coordinates with the `window_to_buffer_coords`() method.

### gtk.TextView.buffer_to_window_coords

        def buffer_to_window_coords(win, buffer_x, buffer_y)

`win` : | one of the textview windows except `gtk.TEXT_WINDOW_PRIVATE`
`buffer_x` : | buffer x coordinate
`buffer_y` : | buffer y coordinate
Returns : | a tuple containing the window x and y coordinates

The `buffer_to_window_coords`() method returns a tuple containing the x and y coordinates for the window specified by `win` that correspond to the textbuffer coordinates specified by `buffer_x` and `buffer_y`. See the above description for more details on textview window types.

### Note

You can't convert coordinates for a non-existing window (see the `set_border_window_size`() method).

### gtk.TextView.window_to_buffer_coords

        def window_to_buffer_coords(win, window_x, window_y)

`win` : | a textview window except `gtk.TEXT_WINDOW_PRIVATE`
`window_x` : | window x coordinate
`window_y` : | window y coordinate
Returns : | a tuple containing the textbuffer x and y coordinates

The `window_to_buffer_coords`() method returns a tuple containing the textbuffer x and y coordinates corresponding to the `window_x` and`window_y` coordinates in the window specified by `win`, See the above description for more details on textview window types.

### Note

You can't convert coordinates for a non-existing window (see the `set_border_window_size`()) method.

### gtk.TextView.get_window

        def get_window(win)

`win` : | a textview window type
Returns : | a `gtk.gdk.Window`, or `None`

The `get_window`() method returns the `gtk.gdk.Window` corresponding to an area of the textview specified by `win`:

`gtk.TEXT_WINDOW_WIDGET` | The widget window
`gtk.TEXT_WINDOW_TEXT` | The window that holds the text
`gtk.TEXT_WINDOW_LEFT` | The left border window - not displayed by default
`gtk.TEXT_WINDOW_RIGHT` | The right border window - not displayed by default
`gtk.TEXT_WINDOW_TOP` | The top border window - not displayed by default
`gtk.TEXT_WINDOW_BOTTOM` | The bottom border window - not displayed by default
`gtk.TEXT_WINDOW_PRIVATE` | An internal inaccessible `gtk.gdk.Window`

This method returns `None` if the window is nonexistent i.e. if its width or height is 0.

### gtk.TextView.get_window_type

        def get_window_type(window)

`window` : | a window type
Returns : | the window type.

The `get_window_type`() method returns the type of the `gtk.gdk.Window` specified by `window`. This method is used to find out what window type an event corresponds to. If you connect to an event signal on the textview, this method can be called on `event.window` to see what window type it was. See the `get_window`() method for more details on window types.

### gtk.TextView.set_border_window_size

        def set_border_window_size(type, size)

`type` : | a textview border window type
`size` : | the width or height of the window

The `set_border_window_size`() method sets the width of a `gtk.TEXT_WINDOW_LEFT` or `gtk.TEXT_WINDOW_RIGHT` window, or the height of a `gtk.TEXT_WINDOW_TOP` or `gtk.TEXT_WINDOW_BOTTOM` window. This method automatically destroys the corresponding window if the size is set to 0, and creates the window if the size is set to non-zero. This method can only be used for the "border windows", it doesn't work with the `gtk.TEXT_WINDOW_WIDGET`, `gtk.TEXT_WINDOW_TEXT`, or `gtk.TEXT_WINDOW_PRIVATE` windows.

### gtk.TextView.get_border_window_size

        def get_border_window_size(type)

`type` : | a textview border window type
Returns : | the width or height of the textview border window

The `get_border_window_size`() method returns the width or height of the border window of the type specified by `type`. See the `set_border_window_size`() method for more details.

### gtk.TextView.forward_display_line

        def forward_display_line(iter)

`iter` : | a `gtk.TextIter`
Returns : | `True` if `iter` was moved and is not on the end iterator

The `forward_display_line`() method moves the location of `iter` forward by one display line. A textview display line is different from a textbuffer line. Textbuffer lines are paragraphs and are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a textbuffer line. If wrapping is turned off, display lines and textbuffer lines will be the same. Display lines are divided differently for each textview, since they depend on the textview's width and the textview's default wrap mode. Paragraphs are the same in all views, since they depend on the contents of the `gtk.TextBuffer`. This method returns `True` if the location of `iter` moves to a dereferenceable position (i.e. not the end position).

### gtk.TextView.backward_display_line

        def backward_display_line(iter)

`iter` : | a `gtk.TextIter`
Returns : | `True` if `iter` was moved

The `backward_display_line`() method moves the location of `iter` backward by one display line. A textview display line is different from a textbuffer line. Textview lines are paragraphs and are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a textbuffer line. If wrapping is turned off, display lines and textbuffer lines will be the same. Display lines are divided differently for each textview, since they depend on the textview's width and the textview's default wrap mode. Paragraphs are the same in all views, since they depend on the contents of the `gtk.TextBuffer`. This method returns `True` if the location of `iter` moves to a dereferenceable position (i.e. not the end position).

### gtk.TextView.forward_display_line_end

        def forward_display_line_end(iter)

`iter` : | a `gtk.TextIter`
Returns : | `True` if `iter` was moved and is not on the end iterator

The `forward_display_line_end`() method moves the location of `iter` forward to the next display line end. A textview display line is different from a textbuffer line. Textbuffer lines are paragraphs and are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a textbuffer line. If wrapping is turned off, display lines and textbuffer lines will be the same. Display lines are divided differently for each textview, since they depend on the textview's width and the textview's default wrap mode. Paragraphs are the same in all views, since they depend on the contents of the `gtk.TextBuffer`. This method returns `True` if the location of `iter` moves to a dereferenceable position (i.e. not the end position).

### gtk.TextView.backward_display_line_start

        def backward_display_line_start(iter)

`iter` : | a `gtk.TextIter`
Returns : | `True` if `iter` was moved

The `backward_display_line_start`() method moves the location of `iter` backward to the next display line start. A textview display line is different from a textbuffer line. Textbuffer lines are paragraphs and are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a textbuffer line. If wrapping is turned off, display lines and textbuffer lines will be the same. Display lines are divided differently for each textview, since they depend on the textview's width and the textview's default wrap mode. Paragraphs are the same in all views, since they depend on the contents of the `gtk.TextBuffer`. This method returns `True` if the location of `iter` moves to a dereferenceable position (i.e. not the end position).

### gtk.TextView.starts_display_line

        def starts_display_line(iter)

`iter` : | a `gtk.TextIter`
Returns : | `True` if the location of `iter` is at the beginning of a display line

The `starts_display_line`() method returns `True` if the location of `iter` is at the start of a display line. See the `forward_display_line`() method for an explanation of display lines vs. textbuffer lines (paragraphs).

### gtk.TextView.move_visually

        def move_visually(iter, count)

`iter` : | a `gtk.TextIter`
`count` : | the number of characters to move (may be negative)
Returns : | `True` if `iter` moved and is not on the end iterator

The`move_visually`() method moves the location of `iter` by `count` cursor positions. If count is negative the location moves against the normal text direction. Note a cursor position move may move over multiple characters when multiple characters combine to form one grapheme.

### gtk.TextView.add_child_at_anchor

        def add_child_at_anchor(child, anchor)

`child` : | a `gtk.Widget`
`anchor` : | a `gtk.TextChildAnchor` in the textview's `gtk.TextBuffer`

The `add_child_at_anchor`() method adds the widget specified by `child` in the textview, at the `gtk.TextChildAnchor` specified by `anchor`.

### gtk.TextView.add_child_in_window

        def add_child_in_window(child, which_window, xpos, ypos)

`child` : | a `gtk.Widget`
`which_window` : | the textview window `child` should appear in
`xpos` : | the X position of `child` in window coordinates
`ypos` : | the Y position of `child` in window coordinates

The `add_child_in_window`() method adds the widget specified by `child` at the fixed coordinates specified by `xpos` and `ypos` in one of the text widget's windows specified by `which_window`. The window must have nonzero size (see the `set_border_window_size`() method).

### Note

The `child` coordinates are given relative to the `gtk.gdk.Window` specified by `which_window`, and these coordinates have no sane relationship to scrolling. When placing `child` in a `gtk.TEXT_WINDOW_WIDGET` window, scrolling is irrelevant, `child` floats above all scrollable areas. However, placing `child` in one of the scrollable windows (a border windows or the text window), you'll need to compute the correct position of `child` in textbuffer coordinates any time scrolling occurs or textbuffer changes occur, and then call the `move_child`() method to update the child's position. Unfortunately there's no good way to detect that scrolling has occurred, using the current API; a possible hack would be to update all child positions when the scroll adjustments change or the text buffer changes.

### gtk.TextView.move_child

        def move_child(child, xpos, ypos)

`child` : | a child widget in the textview
`xpos` : | the new X position in window coordinates
`ypos` : | the new Y position in window coordinates

The `move_child`() method moves the position of `child` to the location (in its current window) specified by `xpos` and `ypos`.

### gtk.TextView.set_wrap_mode

        def set_wrap_mode(wrap_mode)

`wrap_mode` : | a wrap mode value

The `set_wrap_mode`() method sets the "wrap-mode" property of the textview to the value specified by `wrap_mode`. The value of wrap_mode can be one of: `gtk.WRAP_NONE`, `gtk.WRAP_CHAR`, `gtk.WRAP_WORD` or `gtk.WRAP_WORD_CHAR`. The "wrap-mode" property defines the wrap mode for text that is not influenced by a `gtk.TextTag` that sets its "wrap_mode" attribute.

### gtk.TextView.get_wrap_mode

        def get_wrap_mode()

Returns : | the line wrap setting

The `get_wrap_mode`() method returns the value of the "wrap-mode" property. The value of "wrap-mode" can be one of: `gtk.WRAP_NONE`, `gtk.WRAP_CHAR` or `gtk.WRAP_WORD`. The "wrap-mode" property defines the wrap mode for text that is not influenced by a `gtk.TextTag` that sets its "wrap_mode" attribute.

### gtk.TextView.set_editable

        def set_editable(setting)

`setting` : | if `True` the text is editable by default

The `set_editable`() method sets the "editable" property to the value of `setting`. If `setting` is `True` the text in textview is editable by default. The "editable" property determines the editability of the `gtk.TextView` text that is not influenced by a `gtk.TextTag` that sets its "editable" attribute.

### gtk.TextView.get_editable

        def get_editable()

Returns : | `True` if text is editable by default

The `get_editable`() method returns the value of the "editable" property. The "editable" property determines the editability of the `gtk.TextView` text that is not influenced by a `gtk.TextTag` that sets its "editable" attribute.

### gtk.TextView.set_overwrite

        def set_overwrite(overwrite)

`overwrite` : | if `True` turn on overwrite mode; if `False` turn it off

### Note

This method is available in PyGTK 2.4 and above.

The `set_overwrite`() method sets the "overwrite" property to the value of `overwrite`. If `overwrite` is `True`, inserted text overwrites the existing text.

### gtk.TextView.get_overwrite

        def get_overwrite()

Returns : | `True` if the textview is in overwrite mode

### Note

This method is available in PyGTK 2.4 and above.

The `get_overwrite`() method returns the value of the "overwrite" property. see the `set_overwrite`() method for more information.

### gtk.TextView.set_accepts_tab

        def set_accepts_tab(accepts_tab)

`accepts_tab` : | if `True` pressing the Tab key should insert a tab character; if `False`, pressing the Tab key should move the keyboard focus.

### Note

This method is available in PyGTK 2.4 and above.

The `set_accepts_tab`() method sets the "accepts_tab" property to the value of `accepts_tab`. If `accepts_tab` is `True` a tab character is inserted. If `accepts_tab` is `False` the keyboard focus is moved to the next widget in the focus chain.

### gtk.TextView.get_accepts_tab

        def get_accepts_tab()

Returns : | `True` if pressing the Tab key inserts a tab character, `False` if pressing the Tab key moves the keyboard focus.

### Note

This method is available in PyGTK 2.4 and above.

The `get_accepts_tab`() method returns the value of the "accepts_tab" property. See the `set_accepts_tab()` method for more information.

### gtk.TextView.set_pixels_above_lines

        def set_pixels_above_lines(pixels_above_lines)

`pixels_above_lines` : | the number of pixels above paragraphs

The `set_pixels_above_lines`() method sets the "pixels-above-lines" property to the value of `pixels_above_lines`. The "pixels-above-lines" property determines the number of blank pixels to place above textbuffer lines (paragraphs) in the textview for text that is not influenced by a `gtk.TextTag` that sets its "pixels-above-lines" attribute.

### gtk.TextView.get_pixels_above_lines

        def get_pixels_above_lines()

Returns : | the default number of pixels above paragraphs

The `get_pixels_above_lines`() method returns the value of the "pixels-above-lines" property. The "pixels-above-lines" property determines the number of pixels to put above textbuffer lines (paragraphs) in the textview for text that is not influenced by a `gtk.TextTag` that sets its "pixels-above-lines" attribute.

### gtk.TextView.set_pixels_below_lines

        def set_pixels_below_lines(pixels_below_lines)

`pixels_below_lines` : | the default number of pixels below paragraphs

The `set_pixels_below_lines`() method sets the "pixels-below-lines" property to the value of `pixels_below_lines`. The "pixels-below-lines" property determines the number of blank pixels to place below textbuffer lines (paragraphs) in the textview for text that is not influenced by a `gtk.TextTag` that sets its "pixels-below-lines" attribute.

### gtk.TextView.get_pixels_below_lines

        def get_pixels_below_lines()

Returns : | the default number of blank pixels below paragraphs

The `get_pixels_below_lines`() method returns the value of the "pixels-below-lines" property. The "pixels-below-lines" property determines the number of pixels to put below textbuffer lines (paragraphs) in the textview for text that is not influenced by a `gtk.TextTag` that sets its "pixels-below-lines" attribute.

### gtk.TextView.set_pixels_inside_wrap

        def set_pixels_inside_wrap(pixels_inside_wrap)

`pixels_inside_wrap` : | the default number of pixels between wrapped lines

The `set_pixels_inside_wrap`() method sets the "pixels-inside_wrap" property to the value of `pixels_inside_wrap`. The "pixels-inside_wrap" property determines the number of blank pixels to place between wrapped textbuffer lines (inside paragraphs) for text that is not influenced by a `gtk.TextTag` that sets its "pixels-inside_wrap" attribute.

### gtk.TextView.get_pixels_inside_wrap

        def get_pixels_inside_wrap()

Returns : | the default number of pixels of blank space between wrapped lines

The `get_pixels_inside_wrap`() method returns the value of the "pixels-inside-wrap" property. The "pixels-inside-wrap" property determines the number of pixels to put between wrapped textbuffer lines (inside paragraphs) for text that is not influenced by a `gtk.TextTag` that sets its "pixels-inside-wrap" attribute.

### gtk.TextView.set_justification

        def set_justification(justification)

`justification` : | the text justification

The `set_justification`() method sets the "justification" property to the value of `justification`. The value of justification must be one of: `gtk.JUSTIFY_LEFT`, `gtk.JUSTIFY_RIGHT`, `gtk.JUSTIFY_CENTER` or `gtk.JUSTIFY_FILL`. The "justification" property determines the justification of text in the textview that is not influenced by a `gtk.TextTag` that set its "justification" attribute.

### gtk.TextView.get_justification

        def get_justification()

Returns : | the default justification

The `get_justification`() method returns the value of the "justification" property. the default justification of paragraphs in `text_view`. The value of "justification" must be one of: `gtk.JUSTIFY_LEFT`, `gtk.JUSTIFY_RIGHT`, `gtk.JUSTIFY_CENTER` or `gtk.JUSTIFY_FILL`. The "justification" property determines the justification of text in the textview that is not influenced by a `gtk.TextTag` that set its "justification" attribute.

### gtk.TextView.set_left_margin

        def set_left_margin(left_margin)

`left_margin` : | the default left margin in pixels

The `set_left_margin`() method sets the "left-margin" property to the value of `left_margin`. The "left-margin"property determines the number of pixels of space for the left margin of text that is not influenced by a `gtk.TextTag` that sets its "left_margin" attribute.

### gtk.TextView.get_left_margin

        def get_left_margin()

Returns : | the default left margin in pixels

The `get_left_margin`() method returns the value of the "left_margin" property. The "left-margin"property determines the number of pixels of space for the left margin of text that is not influenced by a `gtk.TextTag` that sets its "left_margin" attribute.

### gtk.TextView.set_right_margin

        def set_right_margin(right_margin)

`right_margin` : | the default right margin in pixels

The `set_right_margin`() method sets the "right-margin" property to the value of `right_margin`. The "right-margin"property determines the number of pixels of space for the right margin of text that is not influenced by a `gtk.TextTag` that sets its "right_margin" attribute.

### gtk.TextView.get_right_margin

        def get_right_margin()

Returns : | the default right margin in pixels

The `get_right_margin`() method returns the value of the "right_margin" property. The "right-margin"property determines the number of pixels of space for the right margin of text that is not influenced by a `gtk.TextTag` that sets its "right_margin" attribute.

### gtk.TextView.set_indent

        def set_indent(indent)

`indent` : | the default indentation in pixels

The `set_indent`() method sets the "indent" property to the value of `indent`. The "indent" property determines the indentation for textview paragraphs that are not influenced by a `gtk.TextTag` that sets its "indent" attribute. The indentation may be negative.

### gtk.TextView.get_indent

        def get_indent()

Returns : | the default number of pixels of indentation

The `get_indent`() method returns the value of the "indent" property. The "indent" property determines the indentation for textview paragraphs that are not influenced by a `gtk.TextTag` that sets its "indent" attribute. The indentation may be negative.

### gtk.TextView.set_tabs

        def set_tabs(tabs)

`tabs` : | the default tabs as a `pango.TabArray`

The `set_tabs`() method sets the "tabs" property to a copy of the value of `tabs`. The "tabs" property contains the custom tab stops for the textview paragraphs that are not influenced by a `gtk.TextTag` that sets its "tabs" attribute.

### gtk.TextView.get_tabs

        def get_tabs()

Returns : | a copy of default tab array, or `None` if "standard" tabs are used

The `get_tabs`() method returns the value of the "tabs" property. The "tabs" property contains the custom tab stops for the textview paragraphs that are not influenced by a `gtk.TextTag` that sets its "tabs" attribute. The returned value will be `None` if "standard" (8-space) tabs are used.

### gtk.TextView.get_default_attributes

        def get_default_attributes()

Returns : | a new `gtk.TextAttributes`

The `get_default_attributes`() method returns a copy of the default `gtk.TextAttributes`. These attributes are used for text unless the text is influenced by a `gtk.TextTag`. You'd typically pass the default attributes in to the `gtk.TextIter.get_attributes`() method to get the attributes in effect at a given text position.

### gtk.TextView.get_hadjustment

        def get_hadjustment()

Returns : | the horizontal adjustment.

### Note

This method is available in PyGTK 2.22 and above.

The `get_hadjustment`() method gets the horizontal-scrolling adjustment.

### gtk.TextView.get_vadjustment

        def get_vadjustment()

Returns : | the vertical adjustment.

### Note

This method is available in PyGTK 2.22 and above.

The `get_vadjustment`() method gets the vertical-scrolling adjustment.

## Signals

### The "backspace" gtk.TextView Signal

        def callback(textview, user_param1, ...)

`textview` : | the object which received the signal.
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

### Note

This signal is available in GTK+ 2.10 and above.

The "backspace" signal is emitted when the Backspace key is pressed.

### The "copy-clipboard" gtk.TextView Signal

        def callback(textview, user_param1, ...)

`textview` : | the textview that received the signal
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "copy-clipboard" signal is emitted when a selection is copied to the clipboard from `textview`.

### The "cut-clipboard" gtk.TextView Signal

        def callback(textview, user_param1, ...)

`textview` : | the textview that received the signal
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "cut-clipboard" signal is emitted when a selection is cut from `textview` to the clipboard.

### The "delete-from-cursor" gtk.TextView Signal

        def callback(textview, delete_type, count, user_param1, ...)

`textview` : | the textview that received the signal
`delete_type` : | the type of deletion
`count` : | the number of deletions to do
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "delete-from-cursor" signal is emitted when a deletion of the type specified by `delete_type` is initiated by user action (e.g. pressing the Delete or Backspace keys). The value of `delete_type` must be one of:

- `gtk.DELETE_CHARS`
- `gtk.DELETE_WORD_ENDS`
- `gtk.DELETE_WORDS`
- `gtk.DELETE_DISPLAY_LINES`
- `gtk.DELETE_DISPLAY_LINE_ENDS`
- `gtk.DELETE_PARAGRAPH_ENDS`
- `gtk.DELETE_PARAGRAPHS`
- `gtk.DELETE_WHITESPACE`

`count` specifies the number of times that deletion should be applied.

### The "insert-at-cursor" gtk.TextView Signal

        def callback(textview, string, user_param1, ...)

`textview` : | the textview that received the signal
`string` : | the text to be inserted
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "insert-at-cursor" signal is emitted when `string` is being inserted in `textview`.

### The "move-cursor" gtk.TextView Signal

        def callback(textview, step_size, count, extend_selection, user_param1, ...)

`textview` : | the textview that received the signal
`step_size` : | the step size to move
`count` : | the number of steps to move
`extend_selection` : | if `True` extend the selection
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "move-cursor" signal is emitted when the cursor is moved by `count` steps of `step_size`. If `extend_selection` is `True` the selection is extended by the cursor movement. The value of step_size must be one of:

`gtk.MOVEMENT_LOGICAL_POSITIONS` | move by graphemes
`gtk.MOVEMENT_VISUAL_POSITIONS` | move by graphemes
`gtk.MOVEMENT_WORDS` | move by words
`gtk.MOVEMENT_DISPLAY_LINES` | move by lines(wrapped lines)
`gtk.MOVEMENT_DISPLAY_LINE_ENDS` | move to line ends(wrapped lines)
`gtk.MOVEMENT_PARAGRAPHS` | move by paragraphs(newline-ended lines)
`gtk.MOVEMENT_PARAGRAPH_ENDS` | move to ends of a paragraph
`gtk.MOVEMENT_PAGES` | move by pages
`gtk.MOVEMENT_BUFFER_ENDS` | move to ends of the buffer

### The "move-focus" gtk.TextView Signal

        def callback(textview, direction, user_param1, ...)

`textview` : | the textview that received the signal
`direction` : | the direction to move the focus
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "move-focus" signal is emitted when the focus moves from `textview` in the direction specified by `direction` that must be one of: `gtk.DIR_TAB_FORWARD`, `gtk.DIR_TAB_BACKWARD`, `gtk.DIR_UP`, `gtk.DIR_DOWN`, `gtk.DIR_LEFT` or `gtk.DIR_RIGHT`

### The "move-viewport" gtk.TextView Signal

        def callback(textview, scrollstep, count, user_param1, ...)

`textview` : | the textview that received the signal
`scrollstep` : | the size of the scroll step: `gtk.SCROLL_STEPS`, `gtk.SCROLL_PAGES`, `gtk.SCROLL_ENDS`, `gtk.SCROLL_HORIZONTAL_STEPS`, `gtk.SCROLL_HORIZONTAL_PAGES` or `gtk.SCROLL_HORIZONTAL_ENDS`
`count` : | the number of scroll steps of size `scrollstep` to take
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

### Note

This signal is available in GTK+ 2.4 and above.

The "move-viewport" signal is emitted when the viewport is being moved usually as the result of user action in moving the cursor or using the scrollbars.

### The "page-horizontally" gtk.TextView Signal

        def callback(textview, count, extend_selection, user_param1, ...)

`textview` : | the textview that received the signal
`count` : | the number of pages to move
`extend_selection` : | if `True` extend the selection
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "page-horizontally" signal is emitted when user initiates horizontal paging by pressing one of the key combinations:

Control+Page Up | Page horizontally with `extend_selection` set to `False`
Shift+Control+Page Up | Page horizontally with `extend_selection` set to `True`

### The "paste-clipboard" gtk.TextView Signal

        def callback(textview, user_param1, ...)

`textview` : | the textview that received the signal
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "paste-clipboard" signal is emitted when the contents of the clipboard are pasted into `textview`.

### The "populate-popup" gtk.TextView Signal

        def callback(textview, menu, user_param1, ...)

`textview` : | the textview that received the signal
`menu` : | the menu to populate
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "populate-popup" signal is emitted when the popup menu (specified by `menu`) associated with `textview` needs to be populated.

### The "select-all" gtk.TextView Signal

        def callback(textview, select, user_param1, ...)

`textview` : | the textview that received the signal
`select` : | if `True` select the buffer contents; otherwise deselect the buffer contents
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

### Note

This signal is available in GTK+ 2.2 and above.

The "select-all" signal is emitted when the user presses one of:

- Control+a or Control+/ to select all text in a buffer
- Control+\ to deselect all text in a buffer

### The "set-anchor" gtk.TextView Signal

        def callback(textview, user_param1, ...)

`textview` : | the textview that received the signal
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "set-anchor" signal is emitted when an application calls the `GObject.emit()`() method on textview with "set-anchor" as the signal.

### The "set-scroll-adjustments" gtk.TextView Signal

        def callback(textview, hadjustment, vadjustment, user_param1, ...)

`textview` : | the textview that received the signal
`hadjustment` : | the horizontal adjustment
`vadjustment` : | the vertical adjustment
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "set-scroll-adjustments" signal is emitted when one or both adjustments (specified by `hadjustment` and `vadjustment`) are set on `textview`.

### The "toggle-overwrite" gtk.TextView Signal

        def callback(textview, user_param1, ...)

`textview` : | the textview that received the signal
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "toggle-overwrite" signal is emitted when the user presses the Insert key.

Prev | Up | Next
gtk.TextTagTable | Home | gtk.ToggleAction