本文整理汇总了Python中gi.repository.Gtk.TreeIter方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.TreeIter方法的具体用法?Python Gtk.TreeIter怎么用?Python Gtk.TreeIter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.TreeIter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gtk_list_store_search
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeIter [as 别名]
def gtk_list_store_search(list_store, value, column=0):
"""
Search a :py:class:`Gtk.ListStore` for a value and return a
:py:class:`Gtk.TreeIter` to the first match.
:param list_store: The list store to search.
:type list_store: :py:class:`Gtk.ListStore`
:param value: The value to search for.
:param int column: The column in the row to check.
:return: The row on which the value was found.
:rtype: :py:class:`Gtk.TreeIter`
"""
for row in list_store:
if row[column] == value:
return row.iter
return None
示例2: iter_tree_with_handed_function
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeIter [as 别名]
def iter_tree_with_handed_function(self, function, *function_args):
"""Iterate tree view with condition check function"""
def iter_all_children(row_iter, function, function_args):
if isinstance(row_iter, Gtk.TreeIter):
function(row_iter, *function_args)
for n in reversed(range(self.tree_store.iter_n_children(row_iter))):
child_iter = self.tree_store.iter_nth_child(row_iter, n)
iter_all_children(child_iter, function, function_args)
else:
self._logger.warning("Iter has to be TreeIter -> handed argument is: {0}".format(row_iter))
# iter on root level of tree
next_iter = self.tree_store.get_iter_first()
while next_iter:
iter_all_children(next_iter, function, function_args)
next_iter = self.tree_store.iter_next(next_iter)
示例3: change_fg_colour
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeIter [as 别名]
def change_fg_colour(self, lc, cell, model, m_iter, data):
"""
:Description: Changes the foreground colour of a cell
:param lc: :class:`Gtk.TreeViewColumn` The column we are interested in
:param cell: :class:`Gtk.CellRenderer` The cell we want to change
:param model: :class:`Gtk.TreeModel`
:param iter: :class:`Gtk.TreeIter`
:param data: :py:class:`dict` (key=int,value=bool) value is true if channel already highlighted
:return: None
"""
for chan in data:
if model[m_iter][0] == chan:
if data[chan]:
cell.set_property('foreground_rgba',
Gdk.RGBA(0.9, 0.2, 0.2, 1))
else:
cell.set_property('foreground_rgba', Gdk.RGBA(0, 0, 0, 1))
示例4: test_gtk_list_store_search
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeIter [as 别名]
def test_gtk_list_store_search(self):
store = make_test_list_store()
result = gui_utilities.gtk_list_store_search(store, 'row0 col0', 0)
self.assertIsInstance(result, Gtk.TreeIter)
self.assertEqual(store.get_path(result).to_string(), '0')
result = gui_utilities.gtk_list_store_search(store, 'row1 col1', 1)
self.assertIsInstance(result, Gtk.TreeIter)
self.assertEqual(store.get_path(result).to_string(), '1')
result = gui_utilities.gtk_list_store_search(store, 'fake', 0)
self.assertIsNone(result)
示例5: gtk_treesortable_sort_func_numeric
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeIter [as 别名]
def gtk_treesortable_sort_func_numeric(model, iter1, iter2, column_id):
"""
Sort the model by comparing text numeric values with place holders such as
1,337. This is meant to be set as a sorting function using
:py:meth:`Gtk.TreeSortable.set_sort_func`. The user_data parameter must be
the column id which contains the numeric values to be sorted.
:param model: The model that is being sorted.
:type model: :py:class:`Gtk.TreeSortable`
:param iter1: The iterator of the first item to compare.
:type iter1: :py:class:`Gtk.TreeIter`
:param iter2: The iterator of the second item to compare.
:type iter2: :py:class:`Gtk.TreeIter`
:param column_id: The ID of the column containing numeric values.
:return: An integer, -1 if item1 should come before item2, 0 if they are the same and 1 if item1 should come after item2.
:rtype: int
"""
column_id = column_id or 0
item1 = model.get_value(iter1, column_id).replace(',', '')
item2 = model.get_value(iter2, column_id).replace(',', '')
if item1.isdigit() and item2.isdigit():
return _cmp(int(item1), int(item2))
if item1.isdigit():
return -1
elif item2.isdigit():
return 1
item1 = model.get_value(iter1, column_id)
item2 = model.get_value(iter2, column_id)
return _cmp(item1, item2)
示例6: gtk_treeview_selection_iterate
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeIter [as 别名]
def gtk_treeview_selection_iterate(treeview):
"""
Iterate over the a treeview's selected rows.
:param treeview: The treeview for which to iterate over.
:type treeview: :py:class:`Gtk.TreeView`
:return: The rows which are selected within the treeview.
:rtype: :py:class:`Gtk.TreeIter`
"""
selection = treeview.get_selection()
(model, tree_paths) = selection.get_selected_rows()
if not tree_paths:
return
for tree_path in tree_paths:
yield model.get_iter(tree_path)
示例7: get_history_item_for_tree_iter
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeIter [as 别名]
def get_history_item_for_tree_iter(self, child_tree_iter):
"""Hands history item for tree iter and compensate if tree item is a dummy item
:param Gtk.TreeIter child_tree_iter: Tree iter of row
:rtype rafcon.core.execution.execution_history.HistoryItem:
:return history tree item:
"""
history_item = self.history_tree_store[child_tree_iter][self.HISTORY_ITEM_STORAGE_ID]
if history_item is None: # is dummy item
if self.history_tree_store.iter_n_children(child_tree_iter) > 0:
child_iter = self.history_tree_store.iter_nth_child(child_tree_iter, 0)
history_item = self.history_tree_store[child_iter][self.HISTORY_ITEM_STORAGE_ID]
else:
logger.debug("In a dummy history should be respective real call element.")
return history_item
示例8: do_get_iter
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeIter [as 别名]
def do_get_iter(self, path):
"""Returns a new TreeIter that points at path.
The implementation returns a 2-tuple (bool, TreeIter|None).
"""
indices = path.get_indices()
if indices[0] < self._num_rows:
iter_ = Gtk.TreeIter()
iter_.user_data = indices[0]
return (True, iter_)
else:
return (False, None)
示例9: do_iter_next
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeIter [as 别名]
def do_iter_next(self, iter_):
"""Returns an iter pointing to the next column or None.
The implementation returns a 2-tuple (bool, TreeIter|None).
"""
if iter_.user_data is None and self._num_rows != 0:
iter_.user_data = 0
return (True, iter_)
elif iter_.user_data < self._num_rows - 1:
iter_.user_data += 1
return (True, iter_)
else:
return (False, None)
示例10: do_iter_nth_child
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeIter [as 别名]
def do_iter_nth_child(self, iter_, n):
"""Return iter that is set to the nth child of iter."""
# We've got a flat list here, so iter_ is always None and the
# nth child is the row.
iter_ = Gtk.TreeIter()
iter_.user_data = n
return (True, iter_)
示例11: get_indexpath
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeIter [as 别名]
def get_indexpath(self, treeiter):
'''Get an L{PageIndexRecord} for a C{Gtk.TreeIter}
@param treeiter: a C{Gtk.TreeIter}
@returns: an L{PageIndexRecord} object
'''
mytreeiter = self.get_user_data(treeiter)
if mytreeiter.hint == IS_PAGE:
return PageIndexRecord(mytreeiter.row)
elif mytreeiter.hint == IS_TAG:
return IndexTag(mytreeiter.row['name'], mytreeiter.row['id'])
else:
raise ValueError
示例12: get_indexpath
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeIter [as 别名]
def get_indexpath(self, treeiter):
'''Get an L{PageIndexRecord} for a C{Gtk.TreeIter}
@param treeiter: a C{Gtk.TreeIter}
@returns: an L{PageIndexRecord} object
'''
myiter = self.get_user_data(treeiter)
return PageIndexRecord(myiter.row)
示例13: invalidate_iters
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeIter [as 别名]
def invalidate_iters(self):
"""
This method invalidates all TreeIter objects associated with this custom tree model
and frees their locally pooled references.
"""
self.stamp = random.randint(-2147483648, 2147483647)
self._held_refs.clear()
示例14: iter_is_valid
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeIter [as 别名]
def iter_is_valid(self, iter):
"""
:Returns:
True if the gtk.TreeIter specified by iter is valid for the custom tree model.
"""
return iter.stamp == self.stamp
示例15: get_user_data
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeIter [as 别名]
def get_user_data(self, iter):
"""Get the user_data associated with the given TreeIter.
GenericTreeModel stores arbitrary Python objects mapped to instances of Gtk.TreeIter.
This method allows to retrieve the Python object held by the given iterator.
"""
if self.leak_references:
return self._held_refs[iter.user_data]
else:
return _get_user_data_as_pyobject(iter)