2016-04-21 40 views
0

我在tkinter中遇到typeError问题。我写了这个小测试程序来说明我的问题:tkinter文本插件类型错误

from tkinter import * 

window = Tk() 

Text(window, width=67, height=10).grid() 
Text.insert(END, "test") 

window.mainloop() 

当我运行程序时,我得到这个错误:

TypeError: insert() missing 1 required positional argument: 'chars'

但是,我不知道这种说法。这是没有说或使用在我看到的任何教程(例如effbot

我敢肯定,有一些非常简单,我俯瞰,但我无法找到它为我的生活。

在此先感谢您的帮助!

回答

2

您还没有您的文本组件设置为变量,即使你有grid返回None所以它仍然是行不通的:

from tkinter import * 
window = Tk() 
my_text = Text(window) 
my_text.grid() 
my_text.insert(END, "test") 
window.mainloop() 
+1

啊哈吧。它现在有用,谢谢! – Wichilie