Code Error: TypeError: expected str, bytes or os.PathLike object, not _io.TextIOWrapper Code Error: TypeError: expected str, bytes or os.PathLike object, not _io.TextIOWrapper tkinter tkinter

Code Error: TypeError: expected str, bytes or os.PathLike object, not _io.TextIOWrapper


Use .name attribute to access the file --> window.filename.name.

Ex:

def saveas():    window.filename =  filedialog.asksaveasfile(initialdir = "/",title = "Select file",filetypes = (("text files","*.txt"),("all files","*.*")))    file=open(window.filename.name, 'w')    file.writelines(escritura.get('1.0', END))    file.close()    print(escritura.get('1.0', END))


escritura.get('1.0', END) is maybe an already open file, so maybe you should do escritura.get('1.0', END).read(), since i cant comment yet, can you do type(escritura.get('1.0', END))