|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 小伤口 于 2020-12-21 13:36 编辑 from tkinter import*
def A():
b=ent1.get(1.0,END)
c=int(b)*2
ent2.insert(INSERT,c)
root=Tk()
theButton=Button(root,text='giao!',command=A)
theButton.grid(row=3,column=1,sticky=E,padx=10,pady=5)
ent1=Text(root,width=40,height=2,bg='pink')
ent1.grid(row=0,column=1,padx=10,pady=5)
ent2=Text(root,width=40,height=2,bg='pink').grid(row=100,column=1,padx=10,pady=5)
#俺的纯真想法是输入一个数字通过giao!按钮将数字乘以2返回到第二个文本框
>>> Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 1702, in __call__
return self.func(*args)
File "C:/Users/ASUS/Desktop/嗨.py", line 5, in A
ent2.insert(INSERT,c)
AttributeError: 'NoneType' object has no attribute 'insert'
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 1702, in __call__
return self.func(*args)
File "C:/Users/ASUS/Desktop/嗨.py", line 5, in A
ent2.insert(INSERT,c)
AttributeError: 'NoneType' object has no attribute 'insert'
(报错内容)
为什莫第二个文本框不显示内容呀
如果我要让第二个文本框显示有什么好的解决办法吗?谢谢大佬们了
小小鱼币,不成敬意
ent2=Text(root,width=40,height=2,bg='pink').grid(row=100,column=1,padx=10,pady=5)
这里还是分开吧
修改后如下
from tkinter import *
def A():
b=ent1.get(1.0,END)
c=int(b)*2
ent2.insert(INSERT,c)
root=Tk()
theButton=Button(root,text='giao!',command=A)
theButton.grid(row=3,column=1,sticky=E,padx=10,pady=5)
ent1=Text(root,width=40,height=2,bg='pink')
ent1.grid(row=0,column=1,padx=10,pady=5)
ent2=Text(root,width=40,height=2,bg='pink')
ent2.grid(row=100,column=1,padx=10,pady=5)
#ent2.pack()
#俺的纯真想法是输入一个数字通过giao!按钮将数字乘以2返回到第二个文本框
|
|