def _extract_categories(self): categories = [] for (event, rect) in self.scene.event_data: cat = event.category if cat and not cat in categories: categories.append(cat) return sort_categories(categories)
def _extract_categories(self): categories = [] for (event, rect) in self.scene.event_data: cat = event.category if cat and not cat in categories: categories.append(cat) return sort_categories(categories)
def category_tree(category_list, parent=None, remove=None): """ Transform flat list of categories to a tree based on parent attribute. The top-level categories have the given parent and each level in the tree is sorted. If remove is given then the subtree with remove as root will not be included. The tree is represented as a list of tuples, (cat, sub-tree), where cat is the parent category and subtree is the same tree representation of the children. """ children = [child for child in category_list if (child.parent is parent and child is not remove)] sorted_children = sort_categories(children) tree = [(x, category_tree(category_list, x, remove)) for x in sorted_children] return tree
def category_tree(category_list, parent=None, remove=None): """ Transform flat list of categories to a tree based on parent attribute. The top-level categories have the given parent and each level in the tree is sorted. If remove is given then the subtree with remove as root will not be included. The tree is represented as a list of tuples, (cat, sub-tree), where cat is the parent category and subtree is the same tree representation of the children. """ children = [ child for child in category_list if (child.parent is parent and child is not remove) ] sorted_children = sort_categories(children) tree = [(x, category_tree(category_list, x, remove)) for x in sorted_children] return tree
def select(self, select_category): # We can not do error handling here since this method is also called # from the constructor (and then error handling is done by the code # calling the constructor). self.Clear() self.Append("", None) # The None-category selection_set = False current_item_index = 1 for cat in sort_categories(self.timeline.get_categories()): self.Append(cat.name, cat) if cat == select_category: self.SetSelection(current_item_index) selection_set = True current_item_index += 1 self.last_real_category_index = current_item_index - 1 self.add_category_item_index = self.last_real_category_index + 2 self.edit_categoris_item_index = self.last_real_category_index + 3 self.Append("", None) self.Append(_("Add new"), None) self.Append(_("Edit categories"), None) if not selection_set: self.SetSelection(0) self.current_category_selection = self.GetSelection()
def sort(self, categories): self.sorted_categories = sort_categories(categories)
def sort(self, categories): self.sorted_categories = sort_categories(categories)