I am trying to make a program that will return the user's input and also clear the Entry when Return/Enter is pressed. When ran, the second method (def e_delete(e):) always gives the error, AttributeError: Event instance has no attribute 'delete' and if the e is changed to self no string is returned and no error happens.
from Tkinter import *
import os.path
import PIL.Image, PIL.ImageTk
import Tkinter as tk
def on_change(e):
inp = e.widget.get()
print inp
root = tk.Tk()
#Makes a canvas for objects
canvas = Canvas(root, height=100, width=400)
#Displays the canvas
canvas.grid(row=3, column=2)
root.grid_columnconfigure(0, weight=1)
root.grid_columnconfigure(1, weight=1)
label = Label(root, text="Enter an element or the atomic number from 1 to 118.").grid(row=0, column=2)
e = tk.Entry(root)
e.pack()
e.bind("<Return>", on_change)
e.grid(row=2, column=2)
e.focus()
def e_delete(e):
e.delete(0, 'end')
e.bind("<Return>", e_delete)
#img = create_image(0, 300, 'ptable.png')
root.mainloop()