|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- from tkinter import *
- from tkinter import filedialog
- root = Tk()
- root.geometry("300x200")
- root.resizable(0, 0)
- def show():
- path = filedialog.askopenfilename()
- textvar.set(path)
- file = textvar.get()
- button = Button(root, text='浏览', font=('宋体', 12), command=show)
- button.place(x=238, y=30)
- textvar = StringVar()
- textvar.set('请输入文件路径...')
- filepath = Entry(root, width=25, textvariable=textvar, font=('宋体', 11))
- filepath.place(x=15, y=34)
- mainloop()
复制代码
show 函数中; 得到Entry的字符串内容 ;怎么反回来 以便全后面使用?
比如我想要输出 Entry的字符串内容
给你加上线程打印:
- from tkinter import *
- from tkinter import filedialog
- from threading import Thread
- root = Tk()
- root.geometry("300x200")
- root.resizable(0, 0)
- def show():
- path = filedialog.askopenfilename()
- textvar.set(path)
- global file
- file = textvar.get()
- t.start()
- button = Button(root, text='浏览', font=('宋体', 12), command=show)
- button.place(x=238, y=30)
- file = None
- textvar = StringVar()
- textvar.set('请输入文件路径...')
- filepath = Entry(root, width=25, textvariable=textvar, font=('宋体', 11))
- filepath.place(x=15, y=34)
- def d():
- print(file)
- t = Thread(target=d)
- mainloop()
复制代码
|
|