I have a Python program where I want the user to be able to pick a file from the Python application files but I can't see any way of getting the list of files either natively on the Prime or via Python.
Am I missing something or is this currently not possible?
I can open files that I've added to Python without a problem but I want a list of them so I can display and let the user choose one (no os.listdir() etc).
Thanks
(02-26-2024 01:20 PM)dmh Wrote: [ -> ]I have a Python program where I want the user to be able to pick a file from the Python application files but I can't see any way of getting the list of files either natively on the Prime or via Python.
Am I missing something or is this currently not possible?
I can open files that I've added to Python without a problem but I want a list of them so I can display and let the user choose one (no os.listdir() etc).
Try this:
Code:
from hpprime import eval as ppleval
files = ppleval('AFiles')
The list with file names will be stored in the variable "files".
Perfect - thank you!!!
I actually found some samples using AFiles but they were all reading and writing files and I didn't see this exact example.
(02-26-2024 01:26 PM)komame Wrote: [ -> ] (02-26-2024 01:20 PM)dmh Wrote: [ -> ]I have a Python program where I want the user to be able to pick a file from the Python application files but I can't see any way of getting the list of files either natively on the Prime or via Python.
Am I missing something or is this currently not possible?
I can open files that I've added to Python without a problem but I want a list of them so I can display and let the user choose one (no os.listdir() etc).
Try this:
Code:
from hpprime import eval as ppleval
files = ppleval('AFiles')
The list with file names will be stored in the variable "files".