Forum Archive

File Browser

eliskan175

edit: Solved this!

This question comes with a sexy code for iPad (can be easily modified for iPhone): https://gist.github.com/3508459568dbdfa45c3b

I am working on a file browser, similar to what Windows has. One major goal of this is to only call the GUI when it's needed, avoiding the 'draw' function unless required so this takes less resources.

What I need help on is how to sort the files. As you can see, I have several tables (the size of the file, name, etc) that I need to keep sorted. It would be nice to sort the files by name, size, or other formatting options just like the Windows browser.

Another problem I'm having is how to keep the scrollbar interactive without forcing it to be called every frame. Right now it's pretty laggy. Try it out - the scrollbar button is the purple button, just click and drag it.

Either way, this project is looking very nice so far so it's worth a peek even if you can't help. It is a GUI designed for viewing folders.

It only activates when you click on the screen, or when it first loads. Rotating the screen when it's started tends to bug it out..

eliskan175

Found the solution. I had to make an array within an array and use the sorted function.

So now I have a 'working' file browser for Pythonista (for iPad only). It's a bit crude, but it shows file size, name, type, and can be sorted and works on folders as well. Doesn't have all the functionality of Windows, obviously.

https://gist.github.com/anonymous/ca9e3dca1c570c435e36

The grey box is the scrollbar, just tap it to move and click on folders to open them.

NEW QUESTION: How do I get this to navigate some of my iPad folders, OUTSIDE of Pythonista? Even if it's read-only?

omz

Have a look at @pudquick's excellent Shellista script for some pointers.

eliskan175

Ahh yeah but does that allow me to view files outside of Pythonista?

Here is a more recent version of the filebrowser. It now supports renaming files, moving them, and deleting them. And overall has less bugs.

The newest problem I need to fix is the 'rename hack' - I had to run console BEFORE the draw() scene, because if you run it during draw it causes the entire program to freeze.

In the meantime..

https://gist.github.com/anonymous/6c2d9bf5b04221f675bf

Cubbarooney104

Hmmm... Is there a way to go up (instead of down) through the folders. For example:

[]Pythonista
--[]Mine
----[]Test
--[]Downloaded
----[]Images

Let us pretend this program is stored in "Downloaded". I can only access files in the folder "Downloaded" and its subfolder "Images". The brown box does not allow me to leave the folder "Downloaded" and enter "Pythonista".

Nonetheless, great job!
Cubbarooney

omz

@eliskan With the Shellista script, you can just enter "cd .." to go up in the directory hierarchy... ("ls" to view the contents of the current folder).

Cubbarooney104

@omz I assume you meant me :P

I'm aware of that, but forgot to mention it.

The only problem I have with Shellista is it isn't visual. I use it, and think it is wonderful, but I prefer a good GUI. "Pythonista Explorer" doesn't have all the functionality as Shellista, but I'm sure it will soon!

Cubbarooney

eliskan175

Nah he was talking to me. I asked him earlier in this thread about it. I will research how Shellista does this and try to implement it into my GUI. Ultimately, I would like to browse the contents of my iPad freely, even if I cannot name the objects. I like that transparency.

@Cubbarooney - This app SHOULD be able to always return to the Pythonista root folder if you click the puke brown button. (I know it's a crappy button hehe) But if it's not, I am curious why. is your heirarchy very complex? I have only tried it with about 4 folders and a few nested folders and everything works perfectly, but if there's a bug I'd like to address it! The folders are set up in an array, so when you click a folder the array becomes ["Folder"] and when you click a subfolder it becomes ["Folder","Subfolder"]. When the puke-brown button is clicked it should remove the last object of the array, so pressing it enough should always return to an empty array aka the Pythonista root directory.

I can understand your desire for a GUI. I also wanted one that's why I made this app in the first place :) Also at the time we couldn't see folders lol

Cubbarooney104

Lol, I think omz answered (in a way) both our questions. Nonetheless the puke colored box is not working for me IF you are in the folder you started in. It works otherwise, so you have most of it :P

Cubbaroone