非常に単純な電子メール プログラムを作成しようとしています。ほぼ完成しましたが、ボタンに問題があります。現在、テキストは特定のポイントを通過するとオーバーラップします。
ボタンの私のコードは次のとおりです。おそらく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)