I've trying to make a notepad application - here's my current code:
from tkinter import *
top=Tk()
top.title('Mypad')
def save(self,s):
self.s=filedialog.asksaveasfilename(defaultextension='.txt')
c=open(self.s,'w')
w=c.write(str(e.get('1.0','end')))
def close():
top.destroy()
menubar=Menu(top)
file=Menu(menubar,tearoff=0)
vet=file.add_command(label='Save',command=save)
file.add_separator()
file.add_command(label='Exit',command=close)
menubar.add_cascade(label='File',menu=file)
e=Text()
e.pack(ipady=30)
top.config(menu=menubar)
top.mainloop()
But when I run it and try to save it it is saying like this
Exception in Tkinter callback
Traceback (most recent call last):
File "D:\Workspace\python\lib\tkinter\__init__.py", line 1482, in __call__
return self.func(*args)
TypeError: save() missing 2 required positional arguments: 'self' and 's'
What can I do to fix this?