TypeError: can only concatenate str (not “function”) to str?

ich möchte eine ui für mailtm erstellen aber bekomme kein output raus also wenn email ankommen werden sie nicht angezeigt und wenn ich listener eingebe bekomme ich jedes mal den gleichen fehler code

Fehler code:

TypeError: can only concatenate str (not “function”) to str

from mailtm import *


def listener(message):
    print("\nSubject: " + message['subject'] + str(listener))
    print("Content: " + message['text'] if message['text'] else message['html'] + str(listener))


test = Email()
print("\nDomain: " + test.domain)

test.register()
print("\nEmail Adress: " + str(test.address))


test.start(listener, interval=3)
print("\nHab Sabr.....")


main = ctk.CTk()
main.geometry("500x320")
main.title("Temp mail By Amjn")


emaila = ctk.CTkEntry(main, placeholder_text="         " + test.address, width=900, font=("Helvetica", 20))
emaila.configure(state="readonly")
emaila._corner_radius = 10
emaila.pack()


Copyt = ctk.CTkLabel(main, text="Copy Email", font=("Helvetica", 20))
Copyt.pack()


def neuw(self=None):
    neu = ctk.CTkToplevel(main)
    neu.title("Emails              (MADE BY AMJN)")
    neu.geometry("500x320")
    neu.corner_radius = 30
    neu.resizable(width=True, height=True)

    Ausg = ctk.CTkEntry(neuw, placeholder_text=("         ") + listener, width=900, font=("Helvetica", 20))
    Ausg.pack()


knopf = ctk.CTkButton(main, text="Emails", font=("Helvetica", 20), command=neuw)
knopf.pack(pady=20)

main.mainloop()
(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
6 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
smiregal8472
10 months ago

This is the line:

Ausg = ctk.CTkEntry(neuw, placeholder_text=("         ") + listener, width=900, font=("Helvetica", 20))

listing is a function (which, in addition, even if you would call it at this point) None but also only if you pass exactly one parameter to them).

And also within this function there are some references on listingthat make no sense.

smiregal8472
10 months ago
Reply to  amjnn

what would they do?

The (or at least something in the way):

from mailtm import *
import customtkinter as ctk


class mailtm_gui(ctk.CTk):
    def __init__(self):
        ctk.CTk.__init__(self)
        self.geometry('500x320')
        self.title('Temp mail By Amjn')
        listener = Email()
        listener.register()
        emaila = ctk.CTkEntry(self, placeholder_text=listener.address, width=900, font=('Helvetica', 20))
        emaila.configure(state='readonly')
        emaila._corner_radius = 10
        emaila.pack()
        listener.start(_new_mail, interval=3)

    def _new_mail(self, message):
        mail_window = ctk.CTkToplevel(self)
        mail_window.title('New Mail: ' + message['subject'])
        mail_window.geometry('500x320')
        mail_window.corner_radius = 30
        mail_window.resizable(width=True, height=True)
        mail_body = ctk.CTkEntry(mail_window, placeholder_text='Subject: ' + message['subject'] + '\nBody: ' + (message['text'] if message['text'] else message['html']), width=900, font=('Helvetica', 20))
        mail_body.pack()


if __name__ == '__main__':
    main = mailtm_gui()
    main.mainloop()

MonkeyKing
10 months ago

You did not specify in which line the error is but I guess this is the problem here:

Ausg = ctk.CTkEntry(neuw, placeholder_text=("         ") + listener, width=900, font=("Helvetica", 20))
    Ausg.pack()

listener is not a string, but you manage the function like a string

("         ") + listener

By the way, the clamps by ” are superfluous.