Why am I getting an error message saying: " RefNumCur = RefNumEntry.get() AttributeError: 'NoneType' object has no attribute 'get' "?
Why am I getting an error message saying: " RefNumCur = RefNumEntry.get() AttributeError: 'NoneType' object has no attribute 'get' "?
此代码全部出现在我的增值税计算器程序主菜单屏幕的 class 中。我无法从输入框中检索值。
前几行初始化输入框要使用的文本变量。
RefNumCur = StringVar()
AddressCur = StringVar()
DateCompCur = StringVar()
DateBankCur = StringVar()
JobSourceCur = StringVar()
JobTypeCur = StringVar()
AmountCur = StringVar()
我在这里创建了一个函数,它在将值保存到数据库之前启动一系列有效性算法。但首先我需要从输入框中获取值。
def SaveEntry(*args):
RefNumCur = RefNumEntry.get()
AddressCur = AddressEntry.get()
DateCompCur = DateCompEntry.get()
DateBankCur = DateBankEntry.get()
JobSourceCur = JobSourceEntry.get()
JobTypeCur = JobTypeEntry.get()
AmountCur = AmountEntry.get()
CheckRefNum(RefNumCur)
这是我制作和放置输入框的地方。
RefNumEntry = Entry(textvariable = RefNumCur).grid(row = 2,column =3, columnspan = 2)
AddressEntry = Entry(textvariable = AddressCur).grid(row = 3,column = 3, columnspan = 2)
DateCompEntry = Entry(textvariable = DateCompCur).grid(row = 4,column =3, columnspan = 2)
DateBankEntry = Entry(textvariable = DateBankCur).grid(row = 5,column = 3, columnspan = 2)
JobSourceEntry = Entry(textvariable = JobSourceCur).grid(row = 6, column =3, columnspan = 2)
JobTypeEntry = Entry(textvariable = JobTypeCur).grid(row = 7, column =3, columnspan = 2)
AmountEntry = Entry(textvariable = AmountCur).grid(row = 8,column = 3, columnspan = 2)
grid
returnsNone
。 (pack
、place
相同)
您需要像这样分隔行:
RefNumEntry = Entry(textvariable=RefNumCur).grid(row=2, column=3, columnspan=2)
进入:
RefNumEntry = Entry(textvariable=RefNumCur)
RefNumEntry.grid(row=2, column=3, columnspan=2)
否则,RefNumEntry
将引用 None
而不是 Entry
对象。
此代码全部出现在我的增值税计算器程序主菜单屏幕的 class 中。我无法从输入框中检索值。
前几行初始化输入框要使用的文本变量。
RefNumCur = StringVar()
AddressCur = StringVar()
DateCompCur = StringVar()
DateBankCur = StringVar()
JobSourceCur = StringVar()
JobTypeCur = StringVar()
AmountCur = StringVar()
我在这里创建了一个函数,它在将值保存到数据库之前启动一系列有效性算法。但首先我需要从输入框中获取值。
def SaveEntry(*args):
RefNumCur = RefNumEntry.get()
AddressCur = AddressEntry.get()
DateCompCur = DateCompEntry.get()
DateBankCur = DateBankEntry.get()
JobSourceCur = JobSourceEntry.get()
JobTypeCur = JobTypeEntry.get()
AmountCur = AmountEntry.get()
CheckRefNum(RefNumCur)
这是我制作和放置输入框的地方。
RefNumEntry = Entry(textvariable = RefNumCur).grid(row = 2,column =3, columnspan = 2)
AddressEntry = Entry(textvariable = AddressCur).grid(row = 3,column = 3, columnspan = 2)
DateCompEntry = Entry(textvariable = DateCompCur).grid(row = 4,column =3, columnspan = 2)
DateBankEntry = Entry(textvariable = DateBankCur).grid(row = 5,column = 3, columnspan = 2)
JobSourceEntry = Entry(textvariable = JobSourceCur).grid(row = 6, column =3, columnspan = 2)
JobTypeEntry = Entry(textvariable = JobTypeCur).grid(row = 7, column =3, columnspan = 2)
AmountEntry = Entry(textvariable = AmountCur).grid(row = 8,column = 3, columnspan = 2)
grid
returnsNone
。 (pack
、place
相同)
您需要像这样分隔行:
RefNumEntry = Entry(textvariable=RefNumCur).grid(row=2, column=3, columnspan=2)
进入:
RefNumEntry = Entry(textvariable=RefNumCur)
RefNumEntry.grid(row=2, column=3, columnspan=2)
否则,RefNumEntry
将引用 None
而不是 Entry
对象。