首页 > 编程语言 > 详细

Python 本地文件选择框

时间:2020-09-24 16:16:09      阅读:182      评论:0      收藏:0      [点我收藏+]
from tkinter import filedialog
import tkinter

#定义文件路径选择时间
def Button_command():
    # Folderpath = filedialog.askdirectory()  # 获得选择好的文件夹
    Filepath = filedialog.askopenfilename()  # 获得选择好的文件
    

    t1 = tkinter.StringVar()
    t1.set(Filepath)
    entry = tkinter.Entry(root1, textvariable=t1).place(x=80, y=15)
    print(t1.get())

if __name__ == __main__:
    root1 = tkinter.Tk()
    root1.geometry(300x400)
    root1.wm_title(GUI)
    label0 = tkinter.Label(root1, text=文件路径:)
    label0.place(x=10, y=10)
    t2 = tkinter.Entry(root1, width=20).place(x=80, y=15)
    btn = tkinter.Button(root1, text=...,width=2, height=1,command=Button_command).place(x=240, y=10)
root1.mainloop()

 

Python 本地文件选择框

原文:https://www.cnblogs.com/ouzai/p/13723766.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!