如何使用PyQt4将文件移到不同平台上的回收站/回收站中? [英] How can I move file into Recycle Bin / trash on different platforms using PyQt4?
问题描述
我想向我的跨平台PyQt4应用程序添加下一个功能:当用户选择某个文件并对其选择删除"操作时,该文件将被移动到回收站"文件夹中,而不是被永久删除.我想我可以找到使用Win32 API或类似工具的Windows专用解决方案,但是我想知道类似的操作是否也可以通过PyQt4方法在Ubuntu/Linux和MaxOSX上执行.
I would like to add the next feature to my cross-platform PyQt4 application: when user selects some file and select "remove" action on it that file will be moved to Recycle Bin folder instead of being permantly removed. I think I can find Windows-specific solution using Win32 API or something similar, but I'd like to know does similar operation could be executed on Ubuntu/Linux and MaxOSX as well via PyQt4 methods.
推荐答案
使用Python是一件好事,我不久前创建了一个库来做:
It's a good thing you're using Python, I created a library to do just that a while ago:
http://www.hardcoded. net/articles/send-files-to-rash-on-all-platforms.htm
在PyPI上: Send2Trash
安装
使用conda:
conda install Send2Trash
使用点子:
pip install Send2Trash
用法
删除文件或文件夹
from send2trash import send2trash
send2trash("directory")
这篇关于如何使用PyQt4将文件移到不同平台上的回收站/回收站中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!