python:从输入框中读取

from Tkinter import *

s = 'lll'
def hanshu(ev=None):
    s=entry.get()
    print s

root = Tk()

e = StringVar()

entry = Entry(root,textvariable = e)
e.set('input your text here')

anniu=Button(root,text='ok',command=hanshu) #command=hanshu,绑定函数(不是调用)

entry.pack()
anniu.pack()


root.mainloop()

你可能感兴趣的:(python:从输入框中读取)