为什么我的按钮文本在Tkinter中切换为两行

时间:2013-07-15 23:02:10

标签: button tkinter

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

enter image description here

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

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)

0 个答案:

没有答案