B
B
Ben_r0072020-08-28 21:29:24
Python
Ben_r007, 2020-08-28 21:29:24

How to implement a console file manager in Python?

Hello.
I have an idea to develop an application.
There are console file managers. Not navigation through directories using commands, but in the console, arrows can navigate through folders and files.
It needs to be done as Total Commander. Where are 2 columns (2 directories) between which you can navigate with a tab.
While I'm thinking about how to implement moving through folders and files. Either take the output of the ls command or some method to list the current folders and files in the current directory to a temporary text file, or write them to the list.
Interested in general. How to implement? What libraries to use? Some general algorithm.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

5 answer(s)
D
Dr. Bacon, 2020-08-28
@bacon

Score

G
Gennady S, 2020-08-28
@gscraft

Heh, you are asking to literally outline the stack and part of the application architecture for you, but at the same time you have a poor understanding of the subject, judging by the desire to use output to a file (without resorting to the obvious use of built-in language functions). So what libraries should you use? The standard language library is sufficient:
https://docs.python.org/3/library/filesys.html
https://docs.python.org/3/library/curses.html
Which algorithm to use? Do what is described. Get file lists, display panels, process input.

T
Ternick, 2020-08-28
@Ternick

I have no idea how you will enter with arrows. This can be done somehow, but in python I have not encountered this, I only know that in C ++ in conio.h there is a getch method that does not block the console for the duration of the input.
I can say more about paths and directories. The whole module os and os.path is needed for this. You can use such imports in this project, but before that, find out what works and how:

from os import listdir # отдаёт в виде масива содержание директории которая передана первым и единственным аргументов
from os.path import isdir # Проверяет является ли ли строка директрией, нужен из-за того, что можно создать папку test.exe, по идее файл, но на самом деле папка.

I advise you to study these both modules, in the imports I indicated a small part of what you need.

S
shurshur, 2020-08-28
@shurshur

To create interfaces look towards things like curses, urwid, npyscreen,

M
MechanicZelenyy, 2020-08-29
@MechanicZelenyy

You can use this article as a starting point.
But it's better to build up the complexity step by step, because you want not just a console utility, but TUI. Make an ls clone first to deal with the files and then make a far clone.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question