1

User inputs text into a text box clicks search and then the text is printed. Right now being printed in the shell is fine as I am still developing this. However, with everything I have read in the docs, what I am doing should work. So I am assuming its something small that I dont see. Please let me know what I am doing wrong.

def save():
   key = entryName.get()
   print(key)

nameField = StringVar()
entryName = Entry(root,textvariable= nameField)
entryName.grid(row=3,column=2)

searchButton = Button(root, text = "Search", command = save())
searchButton.grid(row = 19,column = 2)

1 Answers1

2

The issue seems to be in the line -

searchButton = Button(root, text = "Search", command = save())

You should set the function directly as the value for command argument, not call it and set its return value as argument (which is None , since the function does not return anything) . Example -

searchButton = Button(root, text = "Search", command = save)
Anand S Kumar
  • 88,551
  • 18
  • 188
  • 176