简体   繁体   中英

Tkinter: How to print text into a Label?

I have something like an e-mail storage and I want that the saved information printed out in my Label , but I want that the information stacked among each other.

This is my code, but when I enter another e-mail and password, the current Label text is replaced.

How can I fix that?

def print_data(mail,passwort):
    label_list["text"] = str(mail)+" | "+str(passwort)

def save_info():
    mail = entry_mail.get()
    passwort = entry_passwort.get()
    entry_mail.delete(0, tk.END)
    entry_passwort.delete(0, tk.END)
    print_data(mail,passwort)

you have to store the previous information in a variable. Then use:

label.configure(text= "previous label" + "new text")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM