StringList

class StringList(**properties: Any)

Superclasses: Object

Implemented Interfaces: ListModel, Buildable

Constructors:

StringList(**properties)
new(strings:list=None) -> Gtk.StringList

Constructors

class StringList
classmethod new(strings: Sequence[str] | None = None) StringList

Creates a new GtkStringList with the given strings.

Parameters:

strings – The strings to put in the model

Methods

class StringList
append(string: str) None

Appends string to self.

The string will be copied. See take for a way to avoid that.

Parameters:

string – the string to insert

get_string(position: int) str | None

Gets the string that is at position in self.

If self does not contain position items, None is returned.

This function returns the const char *. To get the object wrapping it, use get_item().

Parameters:

position – the position to get the string for

remove(position: int) None

Removes the string at position from self.

position must be smaller than the current length of the list.

Parameters:

position – the position of the string that is to be removed

splice(position: int, n_removals: int, additions: Sequence[str] | None = None) None

Changes self by removing n_removals strings and adding additions to it.

This function is more efficient than append and remove, because it only emits the ::items-changed signal once for the change.

This function copies the strings in additions.

The parameters position and n_removals must be correct (ie: position + n_removals must be less than or equal to the length of the list at the time this function is called).

Parameters:
  • position – the position at which to make the change

  • n_removals – the number of strings to remove

  • additions – The strings to add

take(string: str) None

Adds string to self at the end, and takes ownership of it.

This variant of append is convenient for formatting strings:

gtk_string_list_take (self, g_strdup_print ("``%d`` dollars", lots));
Parameters:

string – the string to insert

Properties

class StringList
props.item_type: type

The type of items. See get_item_type.

Added in version 4.14.

props.n_items: int

The number of items. See get_n_items.

Added in version 4.14.

props.strings: Sequence[str]

Added in version 4.10.