简体   繁体   English

Python Tkinter 文本插入方法

[英]Python Tkinter Text Insert method

i am writing a chatbot with tkinter GUI and i am having a problem with the Insert method.我正在使用 tkinter GUI 编写聊天机器人,但插入方法有问题。

I defined the chat window like this:我这样定义聊天 window :

chatWindow = tk.Text(root)

i insert the messages to the window like this:我将消息插入到 window 中,如下所示:

chatWindow.insert(tk.END, d_to_insert)

and the interpreter shows me this error:解释器向我显示了这个错误:

self.tk.call((self._w, 'insert', index, chars) + args)
_tkinter.TclError: invalid command name ".!text"

Thanks谢谢

From the amount of code you've provided, I can only tell that there is some widget that has already been destroyed that you're trying to access.从您提供的代码量来看,我只能说有一些小部件已经被破坏,您正在尝试访问。

It would be helpful to debug the error if you provide more code.如果您提供更多代码,则有助于调试错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM