Python Tkinter文本小部件错误
当我在文本框中输入文本值,并单击从该代码生成的GUI表单中的generate按钮时,它不会打印所需的输出,而是出现以下错误Python Tkinter文本小部件错误,python,tkinter,Python,Tkinter,当我在文本框中输入文本值,并单击从该代码生成的GUI表单中的generate按钮时,它不会打印所需的输出,而是出现以下错误 Exception in Tkinter callback Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/__init__.py", line 1699, in __call__
Exception in Tkinter callback
Traceback (most recent call last):
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/__init__.py", line 1699, in __call__
return self.func(*args)
File "/Users/Desktop/tk.py", line 28, in <lambda>
b1 = Button(root, text='Generate', command=(lambda e=ents:
fetch(e)))
File "/Users/Desktop/tk.py", line 7, in fetch
text = text[1].get()
TypeError: get() missing 1 required positional argument: 'index1'
密码
阅读Wiget文档文本,问题得到解决, 我在get方法中使用了索引参数 当前:
text = text[1].get()
修改
text = text[1].get('1.0', 'end')
您是否阅读了有关文本小部件的任何文档?get方法的参数都有很好的文档记录。基本上,继续阅读此处链接的文本Wiget文档,问题就解决了,我使用text=text[1]。get'1.0','end'解决了问题,感谢可能的重复
text = text[1].get('1.0', 'end')