-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個空格並進行縮進即可。 –