Reputation: 9
I am trying to store the values of a Tkinter text box widget as a string to use in the rest of my code. But every time I have an enter function I am getting errors regarding the defying of the command is not possible in the functionCall
.
class text():
master = Tk()
def on_button():
print()
t = Label(master, text="Enter Text ")
e1 = Text(master, width=50, height = 25)
e1.grid(row=0, column =1, rowspan=3, columnspan=4, padx=4, pady=4)
functionCall = Button(master, text='Enter', command=Return)
functionCall.grid(row=4, column=4)
var = StringVar()
def Return(self):
self.TempVar=self.Entry.get()
print(self.TempVar)
I am trying to connect the string inserted with the rest of my code. The concept works with a one-line entry box, but the idea is to have a bigger text box.
Upvotes: 0
Views: 154
Reputation: 2691
You should try something like that. You would use .get
option for Text
widget.
from tkinter import*
master = Tk()
def on_button():
print()
def Return():
TempVar=e1.get("1.0",END)
print(TempVar)
t = Label(master, text="Enter Text ")
t.grid(row=0, column =1, rowspan=3, columnspan=4, padx=4, pady=4)
e1 = Text(master, width=50, height = 25)
e1.grid(row=1, column =1, rowspan=3, columnspan=4, padx=4, pady=4)
functionCall = Button(master, text='Enter', command=Return)
functionCall.grid(row=4, column=4)
Upvotes: 1