I have been working on this simple text editor using Python 3 and Tkinter. This is my first time creating a program with an actual GUI and I have relied only on Tkinter documentation. I managed to create a text editor. However, we I started working on the commands of the Open menu item. I came across an error. It would really help if anyone could explain to me what I am doing wrong, and the proper way to do it.
from tkinter import *
from tkinter.filedialog import LoadFileDialog
from tkinter.filedialog import SaveFileDialog
from tkinter.filedialog import Directory
class textEditor:
#main window
main=Tk()
main.title("Text Editor")
textbox=Text(main)
#commands needed
#filler function
def hello():
print ("Hello")
def doOpen():
file=tkFileDialog.askopenfilename(parent=main,title="Open",mode='r')
fileContents=file.read()
main.textbox.delete(0.0,END)
main.textbox.insert(0.0,fileContents)
#creates menubar
menubar=Menu(main)
#creates file cascading menu
filemenu=Menu(menubar, tearoff=0)
filemenu.add_command(label="Open", command=doOpen)
filemenu.add_command(label="Save", command=hello)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=hello)
filemenu.add_command(label="About", command=hello)
menubar.add_cascade(label="File", menu=filemenu)
#creates edit cascading menu
editmenu=Menu(menubar, tearoff=0)
editmenu.add_command(label="Undo", command=hello)
editmenu.add_command(label="Redo", command=hello)
editmenu.add_command(label="Insert Image", command=hello)
editmenu.add_command(label="Prefernces", command=hello)
menubar.add_cascade(label="Edit", menu=editmenu)
textbox.pack(expand=YES, fill=BOTH)
main.config(menu=menubar)
main.mainloop()
ERROR
Exception in Tkinter callback
Traceback (most recent call last):
File "Q:\PortablePython_1.1_py3.0.1\App\lib\tkinter\__init__.py", line 1399, in __call__
return self.func(*args)
TypeError: doOpen() takes exactly 1 positional argument (0 given)