我的tkinter
条目返回了none
。
我的主要代码也遇到了同样的问题,所以我决定编写一个较小的代码进行测试,但我遇到了同样的问题:
from tkinter import *
root = Tk()
a = Entry(root).grid(row = 0, column = 0)
b = Button(root,text = 'CLICK', command= lambda: test()).grid(row = 2, column = 2)
def test():
print(a.get())
root.mainloop()
答案 0 :(得分:0)
它是entry.grid(...)返回None
我想你想要
from tkinter import *
root = Tk()
a = Entry(root)
a.grid(row = 0, column = 0)
b = Button(root,text = 'CLICK', command= lambda: test()).grid(row = 2, column = 2)
def test():
print(a.get())
root.mainloop()