Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在Tkinter中使用网格函数时get函数不起作用_Python_Tkinter - Fatal编程技术网

Python 在Tkinter中使用网格函数时get函数不起作用

Python 在Tkinter中使用网格函数时get函数不起作用,python,tkinter,Python,Tkinter,我正在用Tkinter GUI制作一个简单的打印程序。我得到了错误 “非类型”对象没有属性“get” 每次我点击打印按钮,我不知道为什么。谢谢你的帮助 from tkinter import* root=Tk() root.title("Communication Aid") root.resizable(0,0) def printing(): printed = Input.get() print(printed) mainframe = Frame(root) mai

我正在用Tkinter GUI制作一个简单的打印程序。我得到了错误

“非类型”对象没有属性“get”

每次我点击打印按钮,我不知道为什么。谢谢你的帮助

from tkinter import*

root=Tk()
root.title("Communication Aid")
root.resizable(0,0)

def printing():
    printed = Input.get()
    print(printed)

mainframe = Frame(root)
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)

button = Button(mainframe, text = "Print", command= printing).grid(column=1, row=2, sticky=W)

Input = Entry(mainframe).grid(column=1, row=1, sticky=W)


root.mainloop()
如果在同一行上指定变量和网格,该变量将保留网格的返回值,即无。在单独的行上指定和栅格

button = Button(mainframe, text = "Print", command= printing)
button.grid(column=1, row=2, sticky=W)

Input = Entry(mainframe)
Input.grid(column=1, row=1, sticky=W)

非常感谢你!我没有发布这个之前已经被回答过的问题,我面临着完成全国中学科学公平竞赛项目的压力,这是一个恼人的问题。谢谢
button = Button(mainframe, text = "Print", command= printing)
button.grid(column=1, row=2, sticky=W)

Input = Entry(mainframe)
Input.grid(column=1, row=1, sticky=W)