Gtk.TreeStore¶
- Subclasses:
None
Methods¶
- Inherited:
GObject.Object (37), Gtk.Buildable (1), Gtk.TreeDragDest (2), Gtk.TreeDragSource (3), Gtk.TreeModel (28), Gtk.TreeSortable (6)
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class Gtk.TreeStore(*column_types)¶
- Bases:
GObject.Object
,Gtk.Buildable
,Gtk.TreeDragDest
,Gtk.TreeDragSource
,Gtk.TreeModel
,Gtk.TreeSortable
- Abstract:
No
- Structure:
A tree-like data structure that can be used with the [class`Gtk`.TreeView].
The
GtkTreeStore
object is a list model for use with aGtkTreeView
widget. It implements the [iface`Gtk`.TreeModel] interface, and consequently, can use all of the methods available there. It also implements the [iface`Gtk`.TreeSortable] interface so it can be sorted by the view. Finally, it also implements the tree ‘drag [iface@Gtk.TreeDragSource]’ and ‘drop [iface@Gtk.TreeDragDest]’ interfaces.GtkTreeStore
is deprecated since GTK 4.10, and should not be used in newly written code. You should use [class`Gtk`.TreeListModel] for a tree-like model object.The
Gtk.TreeStore
implementation of theGtkBuildable
interface allows to specify the model columns with a<columns>
element that may contain multiple<column>
elements, each specifying one model column. The “type” attribute specifies the data type for the column.An example of a UI Definition fragment for a tree store:
``xml <object class=”GtkTreeStore”>
- <columns>
<column type=”gchararray”/> <column type=”gchararray”/> <column type=”gint”/>
</columns>
</object> ``
Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- classmethod new(types)[source]¶
- Parameters:
types ([
GObject.GType
]) – an array ofGType
types for the columns, from first to last- Returns:
a new
GtkTreeStore
- Return type:
Creates a new tree store.
This constructor is meant for language bindings.
Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- append(parent, row=None)[source]¶
- Parameters:
parent (
Gtk.TreeIter
orNone
) – A validGtk.TreeIter
, orNone
row ([
object
] orNone
) – a list of values to apply to the newly inserted row orNone
- Returns:
obj:Gtk.TreeIter pointing to the inserted row
- Return type:
Appends a new row to self. If parent is not
None
, then it will append the new row after the last child of parent, otherwise it will append a row to the top level.The returned iterator will point to the new row. The row will be empty after this function is called if row is
None
. To fill in values, you need to callGtk.TreeStore.set
() orGtk.TreeStore.set_value
().If row isn’t
None
it has to be a list of values which will be used to fill the row.Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- clear()[source]¶
Removes all rows from self
Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- insert(parent, position, row=None)[source]¶
- Parameters:
parent (
Gtk.TreeIter
orNone
) – A validGtk.TreeIter
, orNone
position (
int
) – position to insert the new row, or -1 for lastrow ([
object
] orNone
) – a list of values to apply to the newly inserted row orNone
- Returns:
a
Gtk.TreeIter
pointing to the new row- Return type:
Creates a new row at position. If parent is not
None
, then the row will be made a child of parent. Otherwise, the row will be created at the toplevel. If position is -1 or is larger than the number of rows at that level, then the new row will be inserted to the end of the list.The returned iterator will point to the newly inserted row. The row will be empty after this function is called if row is
None
. To fill in values, you need to callGtk.TreeStore.set
() orGtk.TreeStore.set_value
().If row isn’t
None
it has to be a list of values which will be used to fill the row.Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- insert_after(parent, sibling)[source]¶
- Parameters:
parent (
Gtk.TreeIter
orNone
) – A validGtk.TreeIter
, orNone
sibling (
Gtk.TreeIter
orNone
) – A validGtk.TreeIter
, orNone
row ([
object
] orNone
) – a list of values to apply to the newly inserted row orNone
- Returns:
a
Gtk.TreeIter
pointing to the new row- Return type:
Inserts a new row after sibling. If sibling is
None
, then the row will be prepended to parent ‘s children. If parent and sibling areNone
, then the row will be prepended to the toplevel. If both sibling and parent are set, then parent must be the parent of sibling. When sibling is set, parent is optional.The returned iterator will point to this new row. The row will be empty after this function is called if row is
None
. To fill in values, you need to callGtk.TreeStore.set
() orGtk.TreeStore.set_value
().If row isn’t
None
it has to be a list of values which will be used to fill the row.Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- insert_before(parent, sibling, row=None)[source]¶
- Parameters:
parent (
Gtk.TreeIter
orNone
) – A validGtk.TreeIter
, orNone
sibling (
Gtk.TreeIter
orNone
) – A validGtk.TreeIter
, orNone
row ([
object
] orNone
) – a list of values to apply to the newly inserted row orNone
- Returns:
a
Gtk.TreeIter
pointing to the new row- Return type:
Inserts a new row before sibling. If sibling is
None
, then the row will be appended to parent ‘s children. If parent and sibling areNone
, then the row will be appended to the toplevel. If both sibling and parent are set, then parent must be the parent of sibling. When sibling is set, parent is optional.The returned iterator will point to this new row. The row will be empty after this function is called if row is
None
. To fill in values, you need to callGtk.TreeStore.set
() orGtk.TreeStore.set_value
().If row isn’t
None
it has to be a list of values which will be used to fill the row.Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- insert_with_values(parent, position, columns, values)[source]¶
- Parameters:
parent (
Gtk.TreeIter
orNone
) – A validGtkTreeIter
position (
int
) – position to insert the new row, or -1 for lastcolumns ([
int
]) – an array of column numbersvalues ([
GObject.Value
]) – an array of GValues
- Returns:
An unset
GtkTreeIter
to set the new row- Return type:
iter:
Gtk.TreeIter
A variant of
Gtk.TreeStore.insert_with_values
() which takes the columns and values as two arrays, instead of varargs.This function is mainly intended for language bindings.
Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- is_ancestor(iter, descendant)[source]¶
- Parameters:
iter (
Gtk.TreeIter
) – A validGtkTreeIter
descendant (
Gtk.TreeIter
) – A validGtkTreeIter
- Returns:
true if iter is an ancestor of descendant, and false otherwise
- Return type:
Checks if iter is an ancestor of descendant.
Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- iter_depth(iter)[source]¶
- Parameters:
iter (
Gtk.TreeIter
) – A validGtkTreeIter
- Returns:
The depth of the position pointed by the iterator
- Return type:
Returns the depth of the position pointed by the iterator
The depth will be 0 for anything on the root level, 1 for anything down a level, etc.
Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- iter_is_valid(iter)[source]¶
- Parameters:
iter (
Gtk.TreeIter
) – the iterator to check- Returns:
true if the iter is valid, and false otherwise
- Return type:
Checks if the given iter is a valid iter for this
GtkTreeStore
.This function is slow. Only use it for debugging and/or testing purposes.
Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- move_after(iter, position)[source]¶
- Parameters:
iter (
Gtk.TreeIter
) – AGtkTreeIter
.position (
Gtk.TreeIter
orNone
) – AGtkTreeIter
.
Moves iter in self to the position after position.
iter and position should be in the same level.
Note that this function only works with unsorted stores.
If position is
None
, iter will be moved to the start of the level.Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- move_before(iter, position)[source]¶
- Parameters:
iter (
Gtk.TreeIter
) – AGtkTreeIter
position (
Gtk.TreeIter
orNone
) – AGtkTreeIter
Moves iter in self to the position before position.
iter and position should be in the same level.
Note that this function only works with unsorted stores.
If position is
None
, iter will be moved to the end of the level.Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- prepend(parent, row=None)[source]¶
- Parameters:
parent (
Gtk.TreeIter
orNone
) – A validGtk.TreeIter
, orNone
row ([
object
] orNone
) – a list of values to apply to the newly inserted row orNone
- Returns:
obj:Gtk.TreeIter pointing to the inserted row
- Return type:
Prepends a new row to self. If parent is not
None
, then it will prepend the new row before the first child of parent, otherwise it will prepend a row to the top level.The returned iterator will point to the new row. The row will be empty after this function is called if row is
None
. To fill in values, you need to callGtk.TreeStore.set
() orGtk.TreeStore.set_value
().If row isn’t
None
it has to be a list of values which will be used to fill the row.Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- remove(iter)[source]¶
- Parameters:
iter (
Gtk.TreeIter
) – A validGtkTreeIter
- Returns:
true if iter is still valid, and false otherwise
- Return type:
Removes iter from self.
After being removed, iter is set to the next valid row at that level, or invalidated if it previously pointed to the last one.
Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- set(iter, columns, values)[source]¶
- Parameters:
iter (
Gtk.TreeIter
) – A validGtkTreeIter
for the row being modifiedcolumns ([
int
]) – an array of column numbersvalues ([
GObject.Value
]) – an array of GValues
A variant of gtk_tree_store_set_valist() which takes the columns and values as two arrays, instead of using variadic arguments.
This function is mainly intended for language bindings or in case the number of columns to change is not known until run-time.
Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- set_column_types(types)[source]¶
- Parameters:
types ([
GObject.GType
]) – An array ofGType
types, one for each column
Sets the type of the columns in a tree store.
This function is meant primarily for types that inherit from
GtkTreeStore
, and should only be used when constructing a newGtkTreeStore
.This functions cannot be called after a row has been added, or a method on the
GtkTreeModel
interface is called on the tree store.Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- set_value(iter, column, value)[source]¶
- Parameters:
iter (
Gtk.TreeIter
) – A validGtkTreeIter
for the row being modifiedcolumn (
int
) – column number to modifyvalue (
GObject.Value
) – new value for the cell
Sets the data in the cell specified by iter and column.
The type of value must be convertible to the type of the column.
value can also be a Python value and will be converted to a
GObject.Value
using the corresponding column type (SeeGtk.ListStore.set_column_types
()).Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead
- swap(a, b)[source]¶
- Parameters:
a (
Gtk.TreeIter
) – AGtkTreeIter
.b (
Gtk.TreeIter
) – AnotherGtkTreeIter
.
Swaps a and b in the same level of self.
Note that this function only works with unsorted stores.
Deprecated since version 4.10: Use [class`Gtk`.TreeListModel] instead