Python:tkinter askdirectory的UI替代方案

2024-06-17 15:34:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在使用这个tkinter代码,这样用户就可以为要输出到的文件选择一个目录,这非常好:

    usi.sfl = tkFileDialog.askdirectory() + '/'

但看起来是这样的: No normal human locates files like this

我发现的其他替代方法包括:Better, but the lack of favorites on the left is concerning

我希望是这样的: The dream

我做了很多搜索,但没有找到任何能满足我需要的东西。我想它一定在外面,但我就是找不到。任何帮助都将不胜感激。你知道吗


Tags: 文件theno代码用户目录tkinterfiles
1条回答
网友
1楼 · 发布于 2024-06-17 15:34:46

我一直在使用tkinteraskdirectory来做同样的事情,它工作得非常完美。你知道吗

也许修改代码会有帮助?你知道吗

from tkinter import filedialog as fd
directory=fd.askdirectory()

现在目录是一个变量,可以用来读/写文件。你知道吗

要写入此目录中的文件,可以通过使用os.path.join()将filenname字符串添加到目录来指定文件名

import os
fileout = os.path.join(directory + '/<filename>.<ext>')

相关问题 更多 >