def testCheckNode(self): """ Test checking the node type """ db = self.getDB() num_trees, matched_words = cf.searchDB(db, "fearh") test_source = matched_words[0][1] test_root = matched_words[0][0] self.assertEqual(cf.checkNode(test_source), "word") self.assertRaises(cf.EtymExceptWord, cf.checkNode, None) self.assertEqual(cf.checkNode(test_root), "tree")
def DragTreeItem(self, event): """ Initiate a drag-and-drop for the tree """ # This is only allowable under edit mode if self.edit_mode: self._drag_node = self.treebox.GetPyData(event.GetItem()) node_type = cf.checkNode(self._drag_node) # We let words be moved, but not the tree root if node_type == 'word': event.Allow() elif node_type == 'tree': event.Veto()
def TreeItemDelete(self, event): """ Delete the selected tree item """ # Find what type of node it is (word or tree root) node_type = cf.checkNode(self.current_node) # Delete the word or tree if node_type == 'word': cf.deleteWord(self.current_node) elif node_type == 'tree': cf.deleteTree(self.current_node) self.search_root = self.search_words = None # Refresh the tree self.DisplayTree(self.search_root, self.search_words)