0

我正在尝试创建一个非常简单的电子邮件程序。它几乎完成了,但我遇到了按钮问题。目前,文本一旦通过某个点就会重叠。

截屏

我的按钮代码如下。我猜它可能与 for 循环有关:

def mainFun(self):
    """Holds body of thing"""

    #Main Frame
    self.mainFrame = Frame(self)
    self.mainFrame.grid(row = 0, column = 2, sticky = N)

    mail = imaplib.IMAP4_SSL('imap.gmail.com')#Connect to the Server
    mail.login('someemail.com', 'somepassword')#Login
    mail.list() #Different Gmail Labels
    mail.select("inbox") #Select the Label "inbox"

    result, data = mail.uid('search',None, "ALL")

    uid = data[0] #The data is a list
    uid_list = uid.split() #ids is a space separated string
    latest_email_uid = uid_list[-2] #Get the Latest

    for i in range(1, 11):

        x = -i
        email_number = i
        email_uid = uid_list[x]
        result, data = mail.uid('fetch',email_uid, "(RFC822)") #Fetch the Email's body (RFC822) for the given ID

        raw_email = data[0][1] #Raw data of the Email - needs to be parsed. Includes headers and the body

        email_message = email.message_from_string(raw_email) #Convert the raw email into string format

        self.newmessage = Button(self.mainFrame,
                                 text = "Email %d:  %s\n" % (email_number, email_message['Subject']),
                                 anchor = W)
        self.newmessage.config(height = 3, width = 100)
        self.newmessage.grid(column = 0, row = i, sticky = NW)
4

0 回答 0