- 帖子
- 6
- 精华
- 0
- 积分
- 40
- 阅读权限
- 10
- 注册时间
- 2017-7-30
- 最后登录
- 2017-8-27
|
Python的版本是3.6,代码如下
from tkinter import *
def p():
print(text1.get(0))
root=Tk()
text1 = Text(root)
b=Button(root,text="按钮3",command=p)
root.mainloop()
运行后在文本框内输入文字,再按下Button后,报错:
print(text1.get(0))
AttributeError: 'NoneType' object has no attribute 'get'
查看有关的资料,应该是用get方法没错啊
get(startindex [,endindex])
This method returns a specific character or a range of text.
求crossin先生指导
P.S.如果想要把原程序中print的信息实时反馈在tkinter的界面中,是使用Text.insert的方法吗? |
|