Repository navigation
Replies: 1 comment
|
Use from pathlib import PurePath
def require_extensionless(files):
files = files or []
rejected = [f.name for f in files if PurePath(f.name).suffix]
if rejected:
raise ValueError(
"Choose files without an extension: " + ", ".join(rejected)
)
return filesIn the older event-based FilePicker API, apply this to files = await picker.pick_files(file_type=ft.FilePickerFileType.ANY)
try:
accepted = require_extensionless(files)
except ValueError as error:
# Show str(error) in your UI; do not process the rejected selection.
return
# Process accepted here; [] also covers cancellation.This validates after selection; files with extensions remain visible in the native picker. If hiding them is essential, you would need a custom file-browser UI rather than an extension allowlist.
References: Flet FilePicker options, Python suffix semantics. |
Uh oh!
There was an error while loading. Please reload this page.
Question
I need the user to be able to select only files WITHOUT an extension when activating FilePicker. How do I specify this in allowed_extensions? And is there any way to do this?
Code sample
No response
Error message
No response
------------------------------------------------------
All reactions