def onDelete(self, event): selected = self.GetFirstSelected() item = self.GetItem(selected, 0) name = item.GetText() model = self.fmf.model try: del model[name] self.DeleteItem(selected) HKEConfig.remove_loaded_file(name=name) except KeyError: pass
def onRename(self, event): selected = self.GetFirstSelected() item = self.GetItem(selected, 0) name = item.GetText() model = self.fmf.model dlg = wx.TextEntryDialog(self, 'Insert new name:', 'Rename data model item', name) if dlg.ShowModal() == wx.ID_OK: newname = dlg.GetValue() else: return try: model.rename(name, newname) df = model[newname] HKEConfig.remove_loaded_file(name=name) HKEConfig.add_loaded_file(df, name=newname) self.SetStringItem(selected, 0, newname) except ValueError: print "Item not found in model!"