Gtk.TreeStore¶
| Subclasses: | None | 
|---|
Methods¶
| Inherited: | GObject.Object (37), Gtk.Buildable (10), Gtk.TreeDragDest (2), Gtk.TreeDragSource (3), Gtk.TreeModel (27), Gtk.TreeSortable (6) | 
|---|---|
| Structs: | GObject.ObjectClass (5) | 
| class | new(types) | 
| append(parent, row=None) | |
| clear() | |
| insert(parent, position, row=None) | |
| insert_after(parent, sibling) | |
| insert_before(parent, sibling, row=None) | |
| insert_with_values(parent, position, columns, values) | |
| is_ancestor(iter, descendant) | |
| iter_depth(iter) | |
| iter_is_valid(iter) | |
| move_after(iter, position) | |
| move_before(iter, position) | |
| prepend(parent, row=None) | |
| remove(iter) | |
| set(iter, columns, values) | |
| set_column_types(types) | |
| set_value(iter, column, value) | |
| swap(a, b) | 
Virtual Methods¶
| Inherited: | GObject.Object (7), Gtk.Buildable (10), Gtk.TreeDragDest (2), Gtk.TreeDragSource (3), Gtk.TreeModel (19), Gtk.TreeSortable (6) | 
|---|
Properties¶
None
Signals¶
| Inherited: | GObject.Object (1), Gtk.TreeModel (5), Gtk.TreeSortable (1) | 
|---|
Fields¶
| Inherited: | GObject.Object (1), Gtk.TreeModel (5), Gtk.TreeSortable (1) | 
|---|
| Name | Type | Access | Description | 
|---|---|---|---|
| parent | GObject.Object | r | 
Class Details¶
- 
class Gtk.TreeStore(*column_types)¶
- Bases: - GObject.Object,- Gtk.Buildable,- Gtk.TreeDragDest,- Gtk.TreeDragSource,- Gtk.TreeModel,- Gtk.TreeSortable- Abstract: - No - Structure: - Gtk.TreeStoreClass- The - Gtk.TreeStoreobject is a list model for use with a- Gtk.TreeViewwidget. It implements the- Gtk.TreeModelinterface, and consequentially, can use all of the methods available there. It also implements the- Gtk.TreeSortableinterface so it can be sorted by the view. Finally, it also implements the tree drag and drop interfaces.- The - Gtk.TreeStoreimplementation of the- Gtk.Buildableinterface 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: - <object class="GtkTreeStore"> <columns> <column type="gchararray"/> <column type="gchararray"/> <column type="gint"/> </columns> </object>- 
classmethod new(types)[source]¶
- Parameters: - types ([ - GObject.GType]) – an array of- GObject.GTypetypes for the columns, from first to last- Returns: - a new - Gtk.TreeStore- Return type: - Gtk.TreeStore- Non vararg creation function. Used primarily by language bindings. 
 - 
append(parent, row=None)[source]¶
- Parameters: - parent (Gtk.TreeIterorNone) – 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 call- Gtk.TreeStore.set() or- Gtk.TreeStore.set_value().- If row isn’t - Noneit has to be a list of values which will be used to fill the row.
- parent (
 - 
insert(parent, position, row=None)[source]¶
- Parameters: - parent (Gtk.TreeIterorNone) – A validGtk.TreeIter, orNone
- position (int) – position to insert the new row, or -1 for last
- row ([object] orNone) – a list of values to apply to the newly inserted row orNone
 - Returns: - a - Gtk.TreeIterpointing 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 call- Gtk.TreeStore.set() or- Gtk.TreeStore.set_value().- If row isn’t - Noneit has to be a list of values which will be used to fill the row.
- parent (
 - 
insert_after(parent, sibling)[source]¶
- Parameters: - parent (Gtk.TreeIterorNone) – A validGtk.TreeIter, orNone
- sibling (Gtk.TreeIterorNone) – A validGtk.TreeIter, orNone
- row ([object] orNone) – a list of values to apply to the newly inserted row orNone
 - Returns: - a - Gtk.TreeIterpointing 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 are- None, 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 call- Gtk.TreeStore.set() or- Gtk.TreeStore.set_value().- If row isn’t - Noneit has to be a list of values which will be used to fill the row.
- parent (
 - 
insert_before(parent, sibling, row=None)[source]¶
- Parameters: - parent (Gtk.TreeIterorNone) – A validGtk.TreeIter, orNone
- sibling (Gtk.TreeIterorNone) – A validGtk.TreeIter, orNone
- row ([object] orNone) – a list of values to apply to the newly inserted row orNone
 - Returns: - a - Gtk.TreeIterpointing 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 are- None, 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 call- Gtk.TreeStore.set() or- Gtk.TreeStore.set_value().- If row isn’t - Noneit has to be a list of values which will be used to fill the row.
- parent (
 - 
insert_with_values(parent, position, columns, values)[source]¶
- Parameters: - parent (Gtk.TreeIterorNone) – A validGtk.TreeIter, orNone
- position (int) – position to insert the new row, or -1 for last
- columns ([int]) – an array of column numbers
- values ([GObject.Value]) – an array of GValues
 - Returns: - An unset - Gtk.TreeIterto set the new row, or- None.- 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.- New in version 2.10. 
- parent (
 - 
is_ancestor(iter, descendant)[source]¶
- Parameters: - iter (Gtk.TreeIter) – A validGtk.TreeIter
- descendant (Gtk.TreeIter) – A validGtk.TreeIter
 - Returns: - True, if iter is an ancestor of descendant- Return type: - Returns - Trueif iter is an ancestor of descendant. That is, iter is the parent (or grandparent or great-grandparent) of descendant.
- iter (
 - 
iter_depth(iter)[source]¶
- Parameters: - iter ( - Gtk.TreeIter) – A valid- Gtk.TreeIter- Returns: - The depth of iter - Return type: - int- Returns the depth of iter. This will be 0 for anything on the root level, 1 for anything down a level, etc. 
 - 
iter_is_valid(iter)[source]¶
- Parameters: - iter ( - Gtk.TreeIter) – A- Gtk.TreeIter.- Returns: - Trueif the iter is valid,- Falseif the iter is invalid.- Return type: - bool- WARNING: This function is slow. Only use it for debugging and/or testing purposes. - Checks if the given iter is a valid iter for this - Gtk.TreeStore.- New in version 2.2. 
 - 
move_after(iter, position)[source]¶
- Parameters: - iter (Gtk.TreeIter) – AGtk.TreeIter.
- position (Gtk.TreeIterorNone) – AGtk.TreeIter.
 - 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.- New in version 2.2. 
- iter (
 - 
move_before(iter, position)[source]¶
- Parameters: - iter (Gtk.TreeIter) – AGtk.TreeIter.
- position (Gtk.TreeIterorNone) – AGtk.TreeIterorNone.
 - 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.- New in version 2.2. 
- iter (
 - 
prepend(parent, row=None)[source]¶
- Parameters: - parent (Gtk.TreeIterorNone) – 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 call- Gtk.TreeStore.set() or- Gtk.TreeStore.set_value().- If row isn’t - Noneit has to be a list of values which will be used to fill the row.
- parent (
 - 
remove(iter)[source]¶
- Parameters: - iter ( - Gtk.TreeIter) – A valid- Gtk.TreeIter- Returns: - Trueif iter is still valid,- Falseif not.- Return type: - bool- 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. 
 - 
set(iter, columns, values)[source]¶
- Parameters: - iter (Gtk.TreeIter) – A validGtk.TreeIterfor the row being modified
- columns ([int]) – an array of column numbers
- values ([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 varargs. This function is mainly intended for language bindings or in case the number of columns to change is not known until run-time. - New in version 2.12. 
- iter (
 - 
set_column_types(types)[source]¶
- Parameters: - types ([ - GObject.GType]) – An array of- GObject.GTypetypes, one for each column- This function is meant primarily for - GObject.Objectsthat inherit from- Gtk.TreeStore, and should only be used when constructing a new- Gtk.TreeStore. It will not function after a row has been added, or a method on the- Gtk.TreeModelinterface is called.
 - 
set_value(iter, column, value)[source]¶
- Parameters: - iter (Gtk.TreeIter) – A validGtk.TreeIterfor the row being modified
- column (int) – column number to modify
- value (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.Valueusing the corresponding column type (See- Gtk.ListStore.set_column_types()).
- iter (
 - 
swap(a, b)[source]¶
- Parameters: - a (Gtk.TreeIter) – AGtk.TreeIter.
- b (Gtk.TreeIter) – AnotherGtk.TreeIter.
 - Swaps a and b in the same level of self. Note that this function only works with unsorted stores. - New in version 2.2. 
- a (
 
- 
classmethod