Gtk.Editable


Gtk.Editable — Interface for text-editing widgets

Object Hierarchy:

    GInterface
    ╰── Gtk.Editable

Functions:


Signals:

  • “changed” (editable, user_data)
  • “delete-text” (editable, start_pos, end_pos, user_data)
  • “insert-text” (editable, new_text, new_text_length, position, user_data)

Description:

The Gtk.Editable interface is an interface which should be implemented by text editing widgets, such as GtkEntry and Gtk.SpinButton. It contains functions for generically manipulating an editable widget, a large number of action signals used for key bindings, and several signals that an application can connect to to modify the behavior of a widget.

As an example of the latter usage, by connecting the following handler to Gtk.Editable::insert-text, an application can convert all entry into a widget into uppercase.

Forcing entry to uppercase.
    def add_entry(self, parent):
        entry = Gtk.Entry()
        self.insert_sig = entry.connect("insert_text", self.on_insert_text)
        parent.add(entry)

    def on_insert_text(self, entry, result, length, position):          
        entry.handler_block(self.insert_sig)
        entry.set_text(entry.get_text() + result.upper())
        entry.handler_unblock(self.insert_sig)

        entry.emit_stop_by_name("insert_text")        
        return True

Function Details:

select_region()

select_region (self, start_pos:int, end_pos:int)

Selects a region of text. The characters that are selected are those characters at positions from start_pos up to, but not including end_pos. If end_pos is negative, then thecharacters selected are those characters from start_pos to the end of the text. Note that positions are specified in characters, not bytes. [virtual set_selection_bounds]


insert_text()

insert_text (self, new_text:str, new_text_length:int, position:int) -> position:int

Inserts new_text_length bytes of new_text into the contents of thewidget, at position position. Note that the position is in characters, not in bytes. The function updates position to point after the newly inserted text. [virtual do_insert_text]


delete_text()

delete_text (self, start_pos:int, end_pos:int)

Deletes a sequence of characters. The characters that are deleted are those characters at positions from start_pos up to, but not including end_pos. If end_pos is negative, then the characters deletedare those from start_pos to the end of the text. Note that the positions are specified in characters, not bytes. [virtual do_delete_text]


get_chars()

get_chars (self, start_pos:int, end_pos:int) -> str

Retrieves a sequence of characters. The characters that are retrieved are those characters at positions from start_pos up to, but not including end_pos. If end_pos is negative, then the charactersretrieved are those characters from start_pos to the end of the text. Note that positions are specified in characters, not bytes.

  • Returns: a pointer to the contents of the widget as astring. This string is allocated by the Gtk.Editableimplementation and should be freed by the caller.

cut_clipboard()

cut_clipboard (self)

Removes the contents of the currently selected content in the editable andputs it on the clipboard.


copy_clipboard()

copy_clipboard (self)

Copies the contents of the currently selected content in the editable andputs it on the clipboard.


paste_clipboard()

paste_clipboard (self)

Pastes the content of the clipboard to the current position of thecursor in the editable.


delete_selection()

delete_selection (self)

Deletes the currently selected text of the editable.This call doesn’t do anything if there is no selected text.


set_position()

set_position (self, position:int)

Sets the cursor position in the editable to the given value. The cursor is displayed before the character with the given (base 0) index in the contents of the editable. The value must be less than or equal to the number of characters in the editable. A value of -1 indicates that the position should be set after the last character of the editable. Note that position is in characters, not in bytes.


get_position()

get_position (self) -> int

Retrieves the current position of the cursor relative to the startof the content of the editable. Note that this position is in characters, not in bytes.

  • Returns: the cursor position

set_editable()

set_editable (self, is_editable:bool)

Determines if the user can edit the text in the editablewidget or not.


get_editable()

get_editable (self) -> bool

Retrieves whether editable is editable. SeeGtk.Editable:set_editable().

  • Returns: True if editableis editable.

results matching ""

    No results matching ""