在 Python/wxPython 中访问文件元数据

发布于 2024-11-17 01:35:14 字数 320 浏览 1 评论 0原文

我想编写一个实现 wx.FileDropTarget 的 Python/wxPython 应用程序。这部分很简单。我还想在将文件图标拖到应用程序窗口上时显示文件图标,然后在应用程序窗口中显示带有文件图标(以及其他元数据,可能如大小)的代理。

我想在 Windows 7 上实现此功能。但我有兴趣能够在 OS X 和 Linux 上实现此功能。

我用谷歌搜索并搜索了 Python v2.7.1 文档 - 但没有结果。我对 Windows 的方式有点陌生,所以如果有一种方法可以预测与文件关联的 BMP 或 ICO 文件 - 那么我可以走这条路...

任何示例代码总是值得赞赏的。

I would like to write a Python/wxPython app that implements wx.FileDropTarget. This part is easy. I would also like to show the file icon as it is dragged over the app window and then display a proxy with file icon (and other meta-data, perhaps, like size) within the app window.

I would like to implement this on Windows 7. But I am interested in being able to make this work on OS X and Linux as well.

I have googled and searched through Python v2.7.1 documentation - but to no avail. I am somewhat new the ways of Windows, so if there is a way to divine a BMP or ICO file that is associated with a file - then I am okay with going that route...

Any example code is always appreciated.

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

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

发布评论

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

评论(2

开始看清了 2024-11-24 01:35:14

我认为不仅有一种便携式方法可以完成此任务...在 Windows 平台上,文件类型关联的默认图标存储在系统注册表中(图标位于 exe 资源中的可执行文件除外),而在 Linux 平台上,它依赖于桌面环境,每个都有自己的标准......所以我认为没有一种“通用”方法可以做到这一点。

I think there's not only one portable way to accomplish this ... on windows platforms, default icons for file types associations are stored on the system registry (except for executables where the icon is in the exe resources) and on linux platforms it depends on the desktop environment, each one has its own standards ... so i don't think there's an "universal" way to do that.

半﹌身腐败 2024-11-24 01:35:14

这个示例应该可以帮助您开始在 Windows 中查找文件图标:

from _winreg import *

extension = '.html'

reg = OpenKey(HKEY_CLASSES_ROOT, extension)
(value, vtype) = QueryValueEx(reg, None)
print "file type is:", value

reg = OpenKey(HKEY_CLASSES_ROOT, value + '\DefaultIcon')
(value, vtype) = QueryValueEx(reg, None)
print value, vtype

%ProgramFiles%\Internet Explorer\iexplore.exe,-17 2

...至少在我的系统上是这样。

This example should get you started for finding file icons in windows:

from _winreg import *

extension = '.html'

reg = OpenKey(HKEY_CLASSES_ROOT, extension)
(value, vtype) = QueryValueEx(reg, None)
print "file type is:", value

reg = OpenKey(HKEY_CLASSES_ROOT, value + '\DefaultIcon')
(value, vtype) = QueryValueEx(reg, None)
print value, vtype

%ProgramFiles%\Internet Explorer\iexplore.exe,-17 2

...at least that's what it is on my system.

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