:right-sidebar: True EntryBuffer =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: EntryBuffer(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Subclasses: :class:`~gi.repository.Gtk.PasswordEntryBuffer` A ``GtkEntryBuffer`` hold the text displayed in a ``GtkText`` widget. A single ``GtkEntryBuffer`` object can be shared by multiple widgets which will then share the same text content, but not the cursor position, visibility attributes, icon etc. ``GtkEntryBuffer`` may be derived from. Such a derived class might allow text to be stored in an alternate location, such as non-pageable memory, useful in the case of important passwords. Or a derived class could integrate with an application’s concept of undo/redo. Constructors ------------ .. rst-class:: interim-class .. class:: EntryBuffer :no-index: .. classmethod:: new(initial_chars: str | None, n_initial_chars: int) -> ~gi.repository.Gtk.EntryBuffer Create a new ``GtkEntryBuffer`` object. Optionally, specify initial text to set in the buffer. :param initial_chars: initial buffer text :param n_initial_chars: number of characters in ``initial_chars``, or -1 Methods ------- .. rst-class:: interim-class .. class:: EntryBuffer :no-index: .. method:: delete_text(position: int, n_chars: int) -> int Deletes a sequence of characters from the buffer. ``n_chars`` characters are deleted starting at ``position``. If ``n_chars`` is negative, then all characters until the end of the text are deleted. If ``position`` or ``n_chars`` are out of bounds, then they are coerced to sane values. Note that the positions are specified in characters, not bytes. :param position: position at which to delete text :param n_chars: number of characters to delete .. method:: emit_deleted_text(position: int, n_chars: int) -> None Used when subclassing ``GtkEntryBuffer``. :param position: position at which text was deleted :param n_chars: number of characters deleted .. method:: emit_inserted_text(position: int, chars: str, n_chars: int) -> None Used when subclassing ``GtkEntryBuffer``. :param position: position at which text was inserted :param chars: text that was inserted :param n_chars: number of characters inserted .. method:: get_bytes() -> int Retrieves the length in bytes of the buffer. See :obj:`~gi.repository.Gtk.EntryBuffer.get_length`. .. method:: get_length() -> int Retrieves the length in characters of the buffer. .. method:: get_max_length() -> int Retrieves the maximum allowed length of the text in ``buffer``. .. method:: get_text() -> str Retrieves the contents of the buffer. The memory pointer returned by this call will not change unless this object emits a signal, or is finalized. .. method:: insert_text(position: int, chars: str, n_chars: int) -> int Inserts ``n_chars`` characters of ``chars`` into the contents of the buffer, at position ``position``. If ``n_chars`` is negative, then characters from chars will be inserted until a null-terminator is found. If ``position`` or ``n_chars`` are out of bounds, or the maximum buffer text length is exceeded, then they are coerced to sane values. Note that the position and length are in characters, not in bytes. :param position: the position at which to insert text. :param chars: the text to insert into the buffer. :param n_chars: the length of the text in characters, or -1 .. method:: set_max_length(max_length: int) -> None Sets the maximum allowed length of the contents of the buffer. If the current contents are longer than the given length, then they will be truncated to fit. :param max_length: the maximum length of the entry buffer, or 0 for no maximum. (other than the maximum length of entries.) The value passed in will be clamped to the range 0-65536. .. method:: set_text(chars: str, n_chars: int) -> None Sets the text in the buffer. This is roughly equivalent to calling :obj:`~gi.repository.Gtk.EntryBuffer.delete_text` and :obj:`~gi.repository.Gtk.EntryBuffer.insert_text`. Note that ``n_chars`` is in characters, not in bytes. :param chars: the new text :param n_chars: the number of characters in ``text``, or -1 Properties ---------- .. rst-class:: interim-class .. class:: EntryBuffer :no-index: .. attribute:: props.length :type: int The length (in characters) of the text in buffer. .. attribute:: props.max_length :type: int The maximum length (in characters) of the text in the buffer. .. attribute:: props.text :type: str The contents of the buffer. Signals ------- .. rst-class:: interim-class .. class:: EntryBuffer.signals :no-index: .. method:: deleted_text(position: int, n_chars: int) -> None The text is altered in the default handler for this signal. If you want access to the text after the text has been modified, use ``%G_CONNECT_AFTER``. :param position: the position the text was deleted at. :param n_chars: The number of characters that were deleted. .. method:: inserted_text(position: int, chars: str, n_chars: int) -> None This signal is emitted after text is inserted into the buffer. :param position: the position the text was inserted at. :param chars: The text that was inserted. :param n_chars: The number of characters that were inserted. Virtual Methods --------------- .. rst-class:: interim-class .. class:: EntryBuffer :no-index: .. method:: do_delete_text(position: int, n_chars: int) -> int Deletes a sequence of characters from the buffer. ``n_chars`` characters are deleted starting at ``position``. If ``n_chars`` is negative, then all characters until the end of the text are deleted. If ``position`` or ``n_chars`` are out of bounds, then they are coerced to sane values. Note that the positions are specified in characters, not bytes. :param position: position at which to delete text :param n_chars: number of characters to delete .. method:: do_deleted_text(position: int, n_chars: int) -> None :param position: :param n_chars: .. method:: do_get_length() -> int Retrieves the length in characters of the buffer. .. method:: do_get_text(n_bytes: int) -> str :param n_bytes: .. method:: do_insert_text(position: int, chars: str, n_chars: int) -> int Inserts ``n_chars`` characters of ``chars`` into the contents of the buffer, at position ``position``. If ``n_chars`` is negative, then characters from chars will be inserted until a null-terminator is found. If ``position`` or ``n_chars`` are out of bounds, or the maximum buffer text length is exceeded, then they are coerced to sane values. Note that the position and length are in characters, not in bytes. :param position: the position at which to insert text. :param chars: the text to insert into the buffer. :param n_chars: the length of the text in characters, or -1 .. method:: do_inserted_text(position: int, chars: str, n_chars: int) -> None :param position: :param chars: :param n_chars: Fields ------ .. rst-class:: interim-class .. class:: EntryBuffer :no-index: .. attribute:: parent_instance