4
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()
如何将文本小部件的数据添加到其他文本小部件?如何将数据从一个Tkinter文本小部件复制到另一个?
例如,我试图将text1
中的数据插入到text
,但它不起作用。
我得到一个错误: text.insert(Tkinter.INSERT,text1.get( “1.0”,Tkinter.END)) NameError:全局名称 '的Tkinter' 没有定义 – sourD 2010-02-13 16:00:21
呀,我做了不同的进口然后你在测试。我已经解决了这个问题,但是你这样做会导致问题。 – 2010-02-13 16:03:05
和text.get(“1.0”)只能得到第一个字母,就像我把“你好”并点击按钮它只会打印出第一个字母是“h”:( – sourD 2010-02-13 16:07:22