python利用UI选择路径

 

import tkinter as tk
from tkinter.filedialog import askdirectory

def selectPath():
    path_ = askdirectory()
    path.set(path_)

root = tk.Tk()
path = tk.StringVar()

tk.Label(root,text = "目标路径:").grid(row = 0, column = 0)
tk.Entry(root, textvariable = path).grid(row = 0, column = 1)
tk.Button(root, text = "路径选择", command = selectPath).grid(row = 0, column = 2)
root.mainloop()

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
  • 2021-12-06
  • 2021-11-28
  • 2021-04-30
  • 2021-10-27
  • 2022-01-14
猜你喜欢
  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
  • 2021-12-30
  • 2021-10-10
相关资源
相似解决方案