python2.7 如何实现不断从entry获取entry.get()并存储
代码如下能否通过button实现fromTkinterimport*master=Tk()e=Entry(master)e.pack()e.focus_set()defc...
代码如下 能否通过button实现
from Tkinter import *
master = Tk()
e = Entry(master)
e.pack()
e.focus_set()
def clr_text():
e.delete(0, END)
def callback():
n = e.get()
def list_n():
a = []
print a
b1 = Button(master, text="get", width=10, command=callback)
b1.pack()
b2 = Button(master, text="clear", width=10, command=clr_text)
b2.pack()
b3 = Button(master, text="comfirm", width=10, command=list_n)
b3.pack()
mainloop() 展开
from Tkinter import *
master = Tk()
e = Entry(master)
e.pack()
e.focus_set()
def clr_text():
e.delete(0, END)
def callback():
n = e.get()
def list_n():
a = []
print a
b1 = Button(master, text="get", width=10, command=callback)
b1.pack()
b2 = Button(master, text="clear", width=10, command=clr_text)
b2.pack()
b3 = Button(master, text="comfirm", width=10, command=list_n)
b3.pack()
mainloop() 展开
1个回答
展开全部
#coding=utf-8
from Tkinter import *
master = Tk()
e = Entry(master)
e.pack()
e.focus_set()
a=[]
global a
def clr_text():
e.delete(0, END)
#a.pop()删除最后一个元素
def callback():
n = e.get()
a.append(n)
def list_n():
print a
b1 = Button(master, text="get", width=10, command=callback)
b1.pack()
b2 = Button(master, text="clear", width=10, command=clr_text)
b2.pack()
b3 = Button(master, text="comfirm", width=10, command=list_n)
b3.pack()
mainloop()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询