我在python
中使用tkinker
编写了一个脚本。当我运行脚本时,它接收一个输入并将其打印到控制台。它工作得很好。你知道吗
我想做的是将任何功能添加到我现有的脚本中,这样当我按get
按钮时,在填充inputbox
后,它将在控制台中打印值并自动退出。同样,我现有的脚本能够打印值。我需要让那个按钮在打印完成后立即退出。在此方面的任何帮助都将不胜感激。你知道吗
以下是我迄今为止尝试过的:
from tkinter import *
master = Tk()
e = Entry(master)
e.pack()
e.focus_set()
callback = lambda : get_val(e.get())
get_val = lambda item: print(item) #this extra function is for further usage
Button(master, text="get", width=10, command=callback).pack()
master.mainloop()
这就是inputbox
的样子:
维护
lambda
语法:关键是调用
master.destroy()
。你知道吗将
callback
函数修改为:相关问题 更多 >
编程相关推荐