I am implementing a GUI based text editor in python.
I have displayed the text area but when I try to use the asksaveasfile method in Tkinter, it shows that the file has
The function name is asksaveasfilename. And it should be qualified as tkFileDialog.asksaveasfilename. And it does not accept mode argument.
Maybe you want to use tkFileDialog.asksaveasfile.
def file_save():
f = tkFileDialog.asksaveasfile(mode='w', defaultextension=".txt")
if f is None: # asksaveasfile return `None` if dialog closed with "cancel".
return
text2save = str(text.get(1.0, END)) # starts from `1.0`, not `0.0`
f.write(text2save)
f.close() # `()` was missing.