I am trying to create a program that collects a count total of the number of unread messages inside an inbox. I am having no issues with collecting the data, the problem I have is in displaying it in real-time into a text box so that when a new mail comes in the number ticks up, instead of creating a new line underneath it, or having to completely restart the program.
After asking this previous question (How to change the data output received externally in realtime within a program's text window?) a great community member of StackOverflow gave me the following code to work through.
Now it appears to collect the data from my inbox as normal, but it isn't posting the results. I think it must have something to do with how I am using [info] but I am at a total loss.
Thank you for your help!
#! /usr/bin/env python3.4
import imaplib
import email
import tkinter as tk
WIDTH = 500
HEIGHT = 500
def update():
mail=imaplib.IMAP4_SSL('imap.gmail.com',993)
mail.login('email"gmail.com','password')
mail.select("Submissions")
typ, messageIDs = mail.search(None, "UNSEEN")
messageIDsString = str( messageIDs[0], encoding='utf8' )
listOfSplitStrings = messageIDsString.split(" ")
number = len(listOfSplitStrings)
if number == 0:
info['text'] = 'no submissions'
else:
info['text'] = '{} submissions[s]'.format(number)
root.after(5000, update)
root = tk.Tk()
root.title('submissions counter')
x = (root.winfo_screenwidth()//2) - (WIDTH//2)
y = (root.winfo_screenheight()//2) - (HEIGHT//2)
root.geometry('{}x{}+{}+{}'.format(WIDTH, HEIGHT, x, y))
info = tk.Label(root, text='no submissions')
info.pack
update()
root.mainloop()