zoukankan      html  css  js  c++  java
  • Python 本地文件选择框

    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()
  • 相关阅读:
    前端 --> CSS基础
    前端 css 补充内容
    前端 ---> HTML
    MySQL数据库 -- Navicat、pycharm连接数据库
    mysql数据库 --表查询
    IOC Unity
    泛型2
    泛型1
    特性 Attribute
    里氏替换原则
  • 原文地址:https://www.cnblogs.com/ouzai/p/13723766.html
Copyright © 2011-2022 走看看