0

I have this code using a .get() function to retrieve the input from a Tkinter Entry:

from Tkinter import *
def access():
    access_window = Toplevel(root)
    access_window.title("Access a Contact")
    Label(access_window, text="Enter a first name: ").grid(row=0, sticky=W+E)
    access_key = Entry(access_window, width=8)
    access_key.grid(row=1, sticky=W+E)
    Button(access_window, text="Submit", command=lambda: get_info(str(access_key.get("1.0", "end")))).grid(row=2, sticky=W+E)

But when I click the button, I get this error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 1470, in __call__
    return self.func(*args)
  File "/Users/stephenhjb/Documents/First tkinter", line 17, in <lambda>
    Button(access_window, text="Submit", command=lambda: get_info(str(access_key.get("1.0", "end")))).grid(row=2, sticky=W+E)
TypeError: get() takes exactly 1 argument (3 given)

Why is this happening?

Quintec
  • 1,064
  • 12
  • 22

1 Answers1

1

The method .get() of the Entry object does not accept any parameter. It is used to get the value in the Entry object. (Gets the current contents of the entry field). Do not confuse this .get() with the built-in get() of Python.

Font: http://effbot.org/tkinterbook/entry.htm

rafaels88
  • 839
  • 1
  • 6
  • 19
  • Wow… Thanks! I got confused because another SO post said to use those parameters([here](http://stackoverflow.com/questions/14824163/how-to-get-the-input-from-the-tkinter-text-box-widget)). – Quintec Apr 19 '14 at 00:20