from Tkinter import *
root = Tk()
root.title("Whois Tool")
text = Text()
text1 = Text()
text1.config(width=15, height=1)
text1.pack()
def button1():
text.insert(END, text1)
b = Button(root, text="Enter", width=10, height=2, command=button1)
b.pack()
scrollbar = Scrollbar(root)
scrollbar.pack(side=RIGHT, fill=Y)
text.config(width=60, height=15)
text.pack(side=LEFT, fill=Y)
scrollbar.config(command=text.yview)
text.config(yscrollcommand=scrollbar.set)
root.mainloop()
How can I add the data from a text widget to another text widget?
For example, I’m trying to insert the data in text1 to text, but it is not working.
You are trying to insert a
Textreference at the end of anotherTextwidget (does not make much sense), but what you actually want to do is to copy the contents of aTextwidget to another:Not an intuitive way to do it in my opinion.
"1.0"means line1, column0. Yes, the lines are 1-indexed and the columns are 0-indexed.Note that you may not want to import the entire
Tkinterpackage, usingfrom Tkinter import *. It will likely lead to confusion down the road. I would recommend using:Another option is:
You can choose a short name (like
"tk") of your choice. Regardless, you should stick to one import mechanism for the library.