该【python的tkinter如何获取输入框中的值PythonTkinter从输入框获取文本】是由【鼠标】上传分享,文档一共【2】页,该文档可以免费在线阅读,需要了解更多关于【python的tkinter如何获取输入框中的值PythonTkinter从输入框获取文本】的内容,可以使用淘豆网的站内搜索功能,选择自己适合的文档,以下文字是截取该文章内的部分文字,如需要获得完整电子版,请下载此文档到您的设备,方便您编辑和打印。python的tkinte如r 何获取输⼊框中的值_PythonTkinte从r 输⼊
框获取⽂本
为这个问题的基本性质道歉。特⾦特把我难住了。在
我试图构建⼀个带有菜单栏的应⽤程序,其中⼀个选项会弹出⼀个对话框,⽤户在其中输⼊两个值,然后按“回车”或“取消”按钮。按下
任何⼀个按钮都应该关闭车窗。在
我可以构造主窗⼝和“弹出窗⼝”来输⼊值,我已经看过了所有提取⽂本和在按下按钮后关闭窗⼝的⽰例,但是我还是空的。下⾯是我想使
⽤的框架:from Tkinter import *
#
# Functions to perform functions selected from main window
#
def enter_values():
new_window = Toplevel(root)
Label(new_window, text="Value 1").grid(sticky=W,row=0)
e1=Entry(new_window,width=40).grid(row=0,column=1,sticky=W)
Label(new_window, text="Value 2").grid(pady=20,sticky=W,row=1)
e2=Entry(new_window,width=20).grid(row=1,column=1,pady=20,sticky=W)
ok= Button(new_window, text="Enter",command=lambda: callback("OK")).grid(column=0,row=4,pady=30)
cancel = Button(new_window,text="Cancel",command=lambda: callback("CANCEL")).grid(column=1,row=4,pady=30)
def callback(button):
if button == "OK":
print "OK"
elif button == "CANCEL":
print "Cancel"
else:
print "no idea"
#
# Following section defines the display window
#
root = Tk()
(500,200)
("800x300")
("Some clever title here")
menubar = Menu(root)
filemenu = Menu(menubar, tearoff=0)
(label="New", command=enter_values)
()
(label="Exit", command=)
(label="File", menu=filemenu)
(menu=menubar)
()
python的tkinter如何获取输入框中的值PythonTkinter从输入框获取文本 来自淘豆网m.daumloan.com转载请标明出处.