def load_canvas(canvas, text): for item in canvas.get_all_items(): canvas.remove(item) ascii = preprocess.preprocess(options.Options(), text) figures = aparser.parse(ascii) for f in figures: if isinstance(f, figure.Box): gaphs.Box(f, canvas) elif isinstance(f, figure.Line): gaphs.Line(f, canvas)
def RetrClick(self, event): """Send RETR command""" #TODO add check if a message is deleted i = int(self.retrTc.GetValue()) if self.loginStatus and i <= self.numberOfMsg: form = map(lambda i : str(i) + '\n', self.popObject.retr(i)[1]) self.msg = ('',''.join(form))[1] info = aparser.parse(self.msg) self.subjectTc.SetValue(info['subject']) self.fromTc.SetValue(info['from']) self.readTc.SetValue(info['body']) self.attachLbl.SetLabel('Attachment: %d file(s)' % len(info['attachments'])) s = '' for a in info['attachments']: s += str(info['attachments'].index(a)) + '.' + a.name + ' ' self.attachTc.SetValue(s)
def PrintLoggedIn(self, username, userMsg, passMsg): """Print welcome, user, list of msg""" self.logTc.AppendText(self.popObject.getwelcome() + '\n') self.logTc.AppendText('Welcome back, ' + username + '!\n') statMsg = list(self.popObject.stat()) self.numberOfMsg = statMsg[0] parsed = 'You have ' + str(statMsg[0]) + ' mails = ' + str(statMsg[1]) + ' bytes\n' self.logTc.AppendText(parsed) #print info of all email for i in range(1, statMsg[0]+1): #add \n char to all string form = map(lambda i : str(i) + '\n', self.popObject.retr(i)[1]) msg = ('',''.join(form))[1] info = aparser.parse(msg) s = (str(i), info['date'].split()[0], info['from'], info['subject'], str(len(info['attachments']))) string = '%s %s %20.20s "%30.30s" Att %s' % s #print string + '\n' self.logTc.AppendText(string + '\n')