-1
def TKBox():
    root = Tk()

    def getit():
        print (entry1.get())

    label1 = Label(root, text = "File Name: ")
    label1.grid(row = 0)

    entry1 = Entry(root)
    entry1.grid(row = 0, column = 1)

    button1 = Button(root, text = "Import", command = getit() )
    button1.grid(row = 0, column = 2)

    root.mainloop()

I'm trying to get the input from the entry box and print it, the GUI opens, everything works fine but no output. Tried different things, went through many topics but found nothing that has helped me. What am I doing wrong?

No error message either by the way.

Zizouz212
  • 4,908
  • 5
  • 42
  • 66

1 Answers1

0

It seems like you are calling the function instead of passing it. Try replacing the button definition line with this:

button1 = Button(root, text = "Import", command = getit )
Bharel
  • 23,672
  • 5
  • 40
  • 80