1

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()
Smokeyparkin
  • 103
  • 6

1 Answers1

1
info.pack()

Instead of:

info.pack

A simple mistake anyone could make.

Srevilo
  • 174
  • 1
  • 11
  • Oh yeah and you’ve also used “ instead of @ in the email form, but that’s probably just a typo ;) – Srevilo Jan 18 '18 at 11:41
  • @AD WAN it should, bcuz I don’t see anything wrong with it otherwise. Using pack without the () just returns the function object, and doesn’t actually run it. – Srevilo Jan 18 '18 at 20:24
  • The answer you provided will rather make the label visibly on the window the are a lot of work on the code it posted it self. – AD WAN Jan 19 '18 at 14:25
  • @ADWAN I'm sorry, I don't understand. Could you please clarify? – Srevilo Jan 20 '18 at 02:36