【发布时间】:2021-01-08 15:16:08
【问题描述】:
这是我编辑的代码:
from tkinter import *
class UI:
def __init__(self):
self.root = Tk()
self.text= Text(self.root)
self.text.pack()
self.text.bind("<Return>", self.entry.edit_undo)
self.text.mainloop()
UI()
当我运行它时它会正常运行,但是当diff.node_root.bind() 被触发时,它会显示一个错误,上面写着TypeError: edit_undo() takes 1 positional argument but 2 were given。有人可以帮帮我吗?
【问题讨论】:
-
diff代表类的实例,如self,但我使用不同的名称:) -
这样更好。现在你能告诉我
edit_undo是什么吗? -
edit_undo 是 Text 小部件类 here's the information about it 中的内置方法
-
但我仍然没有得到任何东西:(
-
请看下面我的回答,但也请阅读minimal reproducible example。您的代码仍然无法重现。你使用
self.entry,但从不定义它
标签: python python-3.x tkinter tkinter-text