bia*_*lix 30 python recycle-bin cross-platform qt4 pyqt4
我想在我的跨平台PyQt4应用程序中添加下一个功能:当用户选择某个文件并选择"删除"操作时,该文件将被移动到回收站文件夹而不是永久删除.我想我可以使用Win32 API或类似的东西找到特定于Windows的解决方案,但我想知道在Ubuntu/Linux和MaxOSX上也可以通过PyQt4方法执行类似的操作.
Vir*_*ras 56
你使用Python是一件好事,我刚刚创建了一个库来做这件事:
http://www.hardcoded.net/articles/send-files-to-trash-on-all-platforms.htm
在PyPI上:Send2Trash
安装
使用conda:
conda install Send2Trash
Run Code Online (Sandbox Code Playgroud)
使用点子:
pip install Send2Trash
Run Code Online (Sandbox Code Playgroud)
用法
删除文件或文件夹
from send2trash import send2trash
send2trash("directory")
Run Code Online (Sandbox Code Playgroud)