From 958701efebdfdf634971c89c2d7d017d934c7a8b Mon Sep 17 00:00:00 2001 From: Yader Velásquez Date: Sat, 04 Sep 2010 05:25:20 +0000 Subject: delete option OK --- (limited to 'archivo.py') diff --git a/archivo.py b/archivo.py index e4149f9..55507bf 100644 --- a/archivo.py +++ b/archivo.py @@ -21,6 +21,13 @@ import pickle import gobject from gettext import gettext as _ +def indice_entero(cadena): + '''return an int from a string with tuple sintax''' + cadena = cadena.replace('(','') + cadena = cadena.replace(',','') + cadena = cadena.replace(')','') + return int(cadena) + def crear_modelo(indice): '''create the liststore model for the main block''' archivo = open('files/actividades.pkl', 'rb') @@ -58,3 +65,15 @@ def guardar_dato(indice, contenido): f.flush() f.close() +def borrar_dato(indice,indice_lista): + '''delete the selected content''' + indice_lista = str(indice_lista) + indice = str(indice) + indice_lista = indice_entero(indice_lista) + f = open('files/actividades.pkl', 'rb+wb') + dia = pickle.load(f) + del dia[indice][indice_lista] + f.seek(0) + pickle.dump(dia, f) + f.flush() + f.close() -- cgit v0.9.1