简体   繁体   中英

Python cross platform file explorer

I need to scan a hard disk and display folders and files in some sort of file explorer. I need to do this cross platform. Since I thought this a quite common a task I tried to find a library for this task but didn't find anything.

The exact use case: Via a web interface a user browses his filesystem (ideally including not only all mounted harddisks but also any mounted shared drives, remote locations. Expanding a folder on the web UI would trigger a call to the python component making a user's harddisk browsable via web.

The format of choice for the python/javascript communication is json.

While I know python offers many tools for doing it yourself I don't want to deal with OS differences (getting mounts) and encoding issues.

EDIT: To had to be more precise after the first answers (sorry for that missing in my inital post):

Thanks.

Do you want this file explorer to run in the shell, or would you like a GUI?

If you just want to do it in a shell, I suggest looking at os.listdir; the os.path functions also come in handy. Using listdir, you can easily write a recursive directory lister in around a dozen lines.

There's a "simple" cross-platform GUI example in the GTK2 tutorial which uses the GTK TreeView object; the example program is called filelisting.py .

IMO, the GTK2 tutorial is quite good, but as with any GUI framework there's a fair bit of material to learn if you want to become a competent GTK2 programmer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM