Windows 中用户配置文件的放置位置

发布于 2024-08-21 06:37:37 字数 471 浏览 2 评论 0原文

我正在编写一个 python 库,它有一个每个用户的配置文件,可以由库的用户编辑。该库还生成日志文件。 在 *nix 上,标准似乎是将它们转储到 $HOME/.library_name 中。

但是,我不知道如何对待 Windows 用户。在切换到 Linux 之前,我已经使用 Windows 多年,似乎应用程序倾向于 A)依赖 GUI 配置(我不想开发)或 B)将配置数据转储到注册表中(这对于开发和开发来说很烦人)不能与 *nix 配置文件一起移植)

我目前也在 Windows 上将文件转储到 $HOME/.library_name 中,但这在 Windows 上感觉非常不自然。
我考虑过将其放入 %APPDATA% 中,应用程序数据通常存放在其中,但这也有其自身的问题。我最担心的是,外行用户可能甚至不知道该目录在哪里(与 %HOME/~ 不同),并且用户可编辑的配置文件通常似乎不会放在这里。

Windows 上每用户可编辑配置文件的标准位置是什么?

I'm writing a python library that has a per-user configuration file that can be edited by the user of the library. The library also generates logging files.
On *nix, the standard seems to be to dump them in $HOME/.library_name.

However, I am not sure what to do with Windows users. I've used windows for years before switching to Linux and it seems that applications tended to either A) rely on GUI configuration (which I'd rather not develop) or B) dump configuration data in the registry (which is annoying to develop and not portable with the *nix config files)

I currently am dumping the files into the $HOME/.library_name on windows as well, but this feels very unnatural on Windows.
I've considered placing it into %APPDATA%, where application data tends to live, but this has its own problems though. My biggest concern is that lay users might not even know where that directory is (unlike %HOME/~), and user-editable configuration files don't seem to go here normally.

What is the standard location for per-user editable config files on windows?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

瞄了个咪的 2024-08-28 06:37:37

python appdirs 包很好地找到了应用程序数据的标准位置各种平台。例如,对于 Windows,它使用英语 XP 位置:

C:\Documents and Settings\<User>\Application Data\Local Settings\<AppAuthor>\<AppName>

在 Linux 上,它遵循 XDG 标准:

 ~/.config/<appname>

The python appdirs package does a nice job of finding the standard place for application data on various platforms. E.g. for Windows it uses the English XP location:

C:\Documents and Settings\<User>\Application Data\Local Settings\<AppAuthor>\<AppName>

and on Linux it follows the XDG standard:

 ~/.config/<appname>
孤寂小茶 2024-08-28 06:37:37

%APPDATA% 是放置这些文件的正确位置(可能在您的库的子目录中)。不幸的是,相当多移植到 Windows 的 *nix 应用程序尊重这一点,我最终得到了 .gem、.ssh、.VirtualBox 等文件夹,这些文件夹弄乱了我的主目录,并且没有被隐藏。默认为 *nix。

即使对于不太了解 Windows 目录结构布局的用户,您也可以通过在编辑器中打开配置文件的菜单项(或类似项)来简化操作。

如果可能的话,请为该文件提供一个 GUI 前端,即使它非常简单。 Windows 用户将期待一个工具 |选项菜单项会弹出一个对话框,允许他们设置选项,如果没有选项就会感到不知所措。

%APPDATA% is the right place for these (probably in a subdirectory for your library). Unfortunately a fair number of *nix apps ported to Windows don't respect that and I end up with .gem, .ssh, .VirtualBox, etc., folders cluttering up my home directory and not hidden by default as on *nix.

You can make it easy even for users that don't know much about the layout of the Windows directory structure by having a menu item (or similar) that opens the configuration file in an editor for them.

If possible, do provide a GUI front-end to the file, though, even if it's quite a simple one. Windows users will expect a Tools | Options menu item that brings up a dialog box allowing them to set options and will be non-plussed by not having one.

欢你一世 2024-08-28 06:37:37

在 Windows 上,用户不需要使用可编辑的配置文件来配置应用程序,因此没有标准。
可使用 GUI 进行编辑的配置标准是注册表。

如果您使用 QT(或 PyQT?),那么您可以使用提供抽象层的 QSettings。在 Linux 上它使用配置文件,在 Windows 上它写入注册表。

On windows the user is not expected to configure an application using editable config files so there is no standard.
The standard for configuration which is editable using a GUI is the registry.

If you're using QT (or PyQT?) then you can use QSettings which provide an abstraction layer. On Linux it uses a config file and on windows is writes to the registry.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文