Skip to content

Gtk.TextChildAnchor

class — extends GObject.Object

Marks a spot in a GtkTextBuffer where child widgets can be “anchored”.

The anchor can have multiple widgets anchored, to allow for multiple views.

Constructors

new

@classmethod
def new(cls) -> TextChildAnchor

Creates a new GtkTextChildAnchor.

Usually you would then insert it into a GtkTextBuffer with TextBuffer.insert_child_anchor. To perform the creation and insertion in one step, use the convenience function TextBuffer.create_child_anchor.

new_with_replacement

@classmethod
def new_with_replacement(cls, character: str) -> TextChildAnchor

Creates a new GtkTextChildAnchor with the given replacement character.

Usually you would then insert it into a GtkTextBuffer with TextBuffer.insert_child_anchor.

Parameters:

  • character — a replacement character

Methods

get_deleted

def get_deleted(self) -> bool

Determines whether a child anchor has been deleted from the buffer.

Keep in mind that the child anchor will be unreferenced when removed from the buffer, so you need to hold your own reference (with GObject.Object.ref) if you plan to use this function — otherwise all deleted child anchors will also be finalized.

get_widgets

def get_widgets(self) -> list[Widget]

Gets a list of all widgets anchored at this child anchor.

The order in which the widgets are returned is not defined.