-1
很多感谢您的帮助!现在使用这段代码,我可以获得文本窗口。但是,我无法进入while循环。运行下面的代码段时,出现错误
from tkinter import *
root = Tk()
T = Text(root, height=2, width=30)
T.pack()
T.insert(END, "Just a text Widget\nin two lines\n")
root.mainloop()
while(1):
print("inside for loop")
T.insert(END, "foo")
T.see(END)
如果我改变代码如下,文本窗口不出现。请在这里请求您告诉我如何继续。
from tkinter import *
root = Tk()
T = Text(root, height=2, width=30)
T.pack()
T.insert(END, "Just a text Widget\nin two lines\n")
while(1):
print("inside for loop")
T.insert(END, "foo")
T.see(END)
root.mainloop()
回溯(最近通话最后一个): 文件 “C:\用户\ jee11 \工作区\你好\ jeeva \你好\ text_pad.py”,14号线在 T.insert(END “TEST”) 在插入 self.tk.call((self._w,'insert',index,chars)+ args)文件“C:\ python \ lib \ tkinter \ __ init__.py”,行3266 _tkinter.TclError:无效的命令名称“。!text” –
Jeeva
请修复代码高亮显示。只需在代码前添加4个空格并进行缩进即可。 –