Basically, what I want to achieve is that the user can select a file interactively (as in the "browse" windows)
Basically, what I want to achieve is that the user can select a file interactively (as in the "browse" windows)
I do not know if you want to do it graphically or not, but I tell you how to do it in TUI:
import os
dirs = os.scandir(".") # «.» Hace referencia al directorio actual.
dirs = list(dirs) # dirs es un iterador, lo convertimos a una lista.
for x in range(len(dirs)):
print(x, ".", dirs[x])
dir = int(input("\nSelecciona un directorio: "))
if dir < len(dirs):
print("Has elegido:", dirs[dir])
There are libraries that can cover this task, such as Tkinter
.
Here is a simple example of how to implement it:
from tkinter.filedialog import askopenfilename
archivo = askopenfilename()