def test_empty_construction(self): """Test a simple creating An AsynchTaskProgressBox and then adding keys and dictionaries after creation """ grid = DictionaryGrid() self.assertEqual((grid != None), True) grid.keys = ["key1", "key2"] self.assertEqual(grid.get_model().get_n_columns(), 3) grid.append_row({"key1": "val11", "key2": "val12"}) self.assertEqual(len(grid.get_model()), 1)
def append_row(self, dictionary): """append_row: add a row to the TreeView and to DesktopCouch. If keys are already set up only the the keys in the dictionary matching the keys used for columns will be displayed, though all the key value pairs will be saved to the DesktopCouch. If no keys are set up, and this is the first row, keys will be inferred from the dictionary keys. arguments: dictionary - a dictionary to add to the Treeview and to DesktopCouch """ if dictionary is None: dictionary = {} #Here we add rows to desktopcouch if needed if "__desktopcouch_id" not in dictionary: self._persist_dict_to_couch(dictionary) DictionaryGrid.append_row(self,dictionary)