-2

I'm trying to get a value from a function and i want to put the returned value to a text box on my GUI.

Label(master, text="Enter your message :").grid(column = 0, row = 0)
Label(master, text="Corrected message is :").grid(column = 0, row = 1)
e1 = Entry(master).grid(row=0, column=1)
e2 = Entry(master).grid(row=1, column=1)

In this i need the data that comes from the function to appear in the second text box

Raja
  • 1
  • 2

1 Answers1

0

You can use tk's StringVar and assign it to your entries.

my_input = StringVar()
e1 = Entry(master, textvariable=my_input).grid(row=0, column=1)

my_output = StringVar()
e1 = Entry(master, textvariable=my_output).grid(row=1, column=1)

then you add a button that takes my_input.get() as input, and then sets my_output (your function)

button = Button(master, text='try me', command=modify).grid()

def modify():
    my_output.set('hello ' + my_input.get())