为什么我收到一条错误消息,上面写着:“;RefNumCur=RefNumEntry.get()属性错误:'非eT



这些代码都出现在我的Vat计算器程序的主菜单屏幕的一个类中。我在从输入框中检索值时遇到问题

前几行初始化输入框要使用的文本变量

    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返回None。(与packplace相同)

你需要像这样分开行:

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对象。

相关内容

  • 没有找到相关文章

最新更新