allmsgs file read(self msglist allmsgs split(savemailseparator)[ :full text self hdrlist list(map(self parseheadersself msglist)msg objects def onloadmailfileexit(selfsavetitle)on thread success self title(savetitlereset window title to filename self fillindex(updates guido in main thread self lift(raise my window self openfilebusy decr(def onloadmailfilefail(selfexc_infosavetitle)on thread exception showerror(appname'error opening "% "\ % \ % ((self filename,exc_info[: ])printstack(exc_infoself destroy(always close my windowself openfilebusy decr(not needed if destroy def addsavedmails(selffulltextlist)""optimizationextend loaded file lists for mails newly saved to this window' filein past called loadmailthread to reload entire file on save slowmust be called in main gui thread onlyupdates guisends still reloads sent file if openno msg text""self msglist extend(fulltextlistself hdrlist extend(map(self parseheadersfulltextlist) iter ok self fillindex(self lift(def dodelete(selfmsgnums)""simple-mindedbut sufficientrewrite all nondeleted mails to filecan' just delete from self msglist in-placechanges item indexespy enumerate(lsame as zip(range(len( )) now threadedelse sec pause for large files ""if self openfilebusydont allow parallel open/delete changes errmsg 'cannot deletefile is busy:\ "% "self filename showerror(appnameerrmsgelsesavetitle self title(self title(appname 'deleting 'self openfilebusy incr(threadtools startthreadaction self deletemailfileargs (msgnums,)context (savetitle,)onexit self ondeletemailfileexitonfail self ondeletemailfilefailpymailgui implementation