Gtk.TreePath

Fields

None

Methods

class

new ()

class

new_first ()

class

new_from_indices (indices)

class

new_from_string (path)

append_index (index_)

compare (b)

copy ()

down ()

free ()

get_depth ()

get_indices ()

is_ancestor (descendant)

is_descendant (ancestor)

next ()

prepend_index (index_)

prev ()

to_string ()

up ()

Details

class Gtk.TreePath(*args, **kwargs)
classmethod new()[source]
Returns:

A newly created Gtk.TreePath-struct.

Return type:

Gtk.TreePath

Creates a new Gtk.TreePath-struct. This refers to a row.

classmethod new_first()[source]
Returns:

A new Gtk.TreePath-struct

Return type:

Gtk.TreePath

Creates a new Gtk.TreePath-struct.

The string representation of this path is “0”.

classmethod new_from_indices(indices)[source]
Parameters:

indices ([int]) – array of indices

Returns:

A newly created Gtk.TreePath-struct

Return type:

Gtk.TreePath

Creates a new path with the given indices array of length.

New in version 3.12.

classmethod new_from_string(path)[source]
Parameters:

path (str) – The string representation of a path

Returns:

A newly-created Gtk.TreePath-struct, or None

Return type:

Gtk.TreePath

Creates a new Gtk.TreePath-struct initialized to path.

path is expected to be a colon separated list of numbers. For example, the string “10:4:0” would create a path of depth 3 pointing to the 11th child of the root node, the 5th child of that 11th child, and the 1st child of that 5th child. If an invalid path string is passed in, None is returned.

append_index(index_)[source]
Parameters:

index (int) – the index

Appends a new index to a path.

As a result, the depth of the path is increased.

compare(b)[source]
Parameters:

b (Gtk.TreePath) – a Gtk.TreePath-struct to compare with

Returns:

the relative positions of self and b

Return type:

int

Compares two paths.

If self appears before b in a tree, then -1 is returned. If b appears before self, then 1 is returned. If the two nodes are equal, then 0 is returned.

copy()[source]
Returns:

a new Gtk.TreePath-struct

Return type:

Gtk.TreePath

Creates a new Gtk.TreePath-struct as a copy of self.

down()[source]

Moves self to point to the first child of the current path.

free()[source]

Frees self. If self is None, it simply returns.

get_depth()[source]
Returns:

The depth of self

Return type:

int

Returns the current depth of self.

get_indices()[source]
Returns:

The current indices, or None

Return type:

[int]

Returns the current indices of self.

This is an array of integers, each representing a node in a tree. It also returns the number of elements in the array. The array should not be freed.

New in version 3.0.

is_ancestor(descendant)[source]
Parameters:

descendant (Gtk.TreePath) – another Gtk.TreePath-struct

Returns:

True if descendant is contained inside self

Return type:

bool

Returns True if descendant is a descendant of self.

is_descendant(ancestor)[source]
Parameters:

ancestor (Gtk.TreePath) – another Gtk.TreePath-struct

Returns:

True if ancestor contains self somewhere below it

Return type:

bool

Returns True if self is a descendant of ancestor.

next()[source]

Moves the self to point to the next node at the current depth.

prepend_index(index_)[source]
Parameters:

index (int) – the index

Prepends a new index to a path.

As a result, the depth of the path is increased.

prev()[source]
Returns:

True if self has a previous node, and the move was made

Return type:

bool

Moves the self to point to the previous node at the current depth, if it exists.

to_string()[source]
Returns:

A newly-allocated string. Must be freed with GLib.free().

Return type:

str

Generates a string representation of the path.

This string is a “:” separated list of numbers. For example, “4:10:0:3” would be an acceptable return value for this string.

up()[source]
Returns:

True if self has a parent, and the move was made

Return type:

bool

Moves the self to point to its parent node, if it has a parent.