I've been playing around with python and tkinter, i'm trying to craeat a simple caulator , i got the GUI sorted ,I'm trying to get functionality working so I'm a test programme
I'm having problems get the input from the entry widget. To test this I have a function called get_input that is called when the button is pressed . Then it pass the input to a variable called a and printed to screen.
I keep getting and error
a=e1.get("1",END)
AttributeError: 'NoneType' object has no attribute 'get'
I googled and it said the variable wasn't declared so i set a="", but still not get the input.
Here the code
from Tkinter import *
root = Tk()
master = Frame(root)
master.pack()
# create entry widegt
e1=Entry(master).grid(row=0)
# get the input from e1
def get_input():
a=""
a=e1.get("1",END)
print a
# create buttun and add call back
button1 = Button(master, text="Pres Me",command=get_input)
button1.grid(row=1, column=1)
root.mainloop()
can some explain what I doing wrong,I'm new to python .