I'm trying to save a big list of variables into a text document, but I am getting errors when I click on the "save" button either when I'm using asksaveasfile or asksaveasfilename.
The relevant part of code (it picks about a hundred different variables, but to save space I won't write all of them) is:
from tkinter import *
from tkinter.filedialog import *
def save_doc():
text_file=open(asksaveasfile, mode ='w')
text_file.write(nombrePatrocinado+"\n")
text_file.write(apellidoPaternoPatrocinado+"\n")
text_file.close()
saveDocBTN=Button(text="Save", command=save_doc)
saveDocBTN.grid(row=0,column=6)
When I use this, it says
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3.4/tkinter/__init__.py", line 1536, in __call__
return self.func(*args)
File "/home/juanelo/Downloads/launcher.py", line 662, in save_doc
text_file=open(asksaveasfile, mode ='w')
TypeError: invalid file: <function asksaveasfile at 0xb5e973d4>
The other one I tried is pretty much the same:
from tkinter import *
from tkinter.filedialog import *
def save_doc():
text_file=open(asksaveasfilename)
text_file.write(nombrePatrocinado+"\n")
text_file.write(apellidoPaternoPatrocinado+"\n")
text_file.close()
saveDocBTN=Button(text="Save", command=save_doc)
saveDocBTN.grid(row=0,column=6)
When I try this, I get
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3.4/tkinter/__init__.py", line 1536, in __call__
return self.func(*args)
File "/home/juanelo/Downloads/launcher.py", line 662, in save_doc
text_file=open(asksaveasfilename)
TypeError: invalid file: <function asksaveasfilename at 0xb5df82b4>