python gui点击按钮获取选中多个文件夹路径并显示在文本框中
时间: 2023-03-28 14:04:52 浏览: 195
您好,这个问题可以使用tkinter库来实现。您可以创建一个按钮,然后在按钮的回调函数中使用filedialog.askdirectory()函数来获取选中的文件夹路径,最后将路径显示在文本框中即可。具体实现可以参考以下代码:
```
import tkinter as tk
from tkinter import filedialog
def select_folders():
folders = filedialog.askdirectory(multiple=True)
if folders:
folder_text.delete(1., tk.END)
folder_text.insert(tk.END, "\n".join(folders))
root = tk.Tk()
root.title("Select Folders")
folder_label = tk.Label(root, text="Selected Folders:")
folder_label.pack()
folder_text = tk.Text(root, height=10)
folder_text.pack()
select_button = tk.Button(root, text="Select Folders", command=select_folders)
select_button.pack()
root.mainloop()
```
阅读全文