Closed dokempf closed 5 months ago
If I understand your use case, I think you should be able to use select_default=True
when creating the dialog.
from ipyfilechooser import FileChooser
import os
# Create new FileChooser:
# Path: current directory
# File: test.txt
# Title: <b>FileChooser example</b>
# Show hidden files: no
# Use the default path and filename as selection: yes
# Only show folders: no
fdialog = FileChooser(
os.getcwd(),
filename='test.txt',
title='<b>FileChooser example</b>',
show_hidden=False,
select_default=True,
show_only_dirs=False
)
display(fdialog)
This will show the dialog in a selected (i.e., closed state) with the test.txt
file in the current folder as the selected value. Let me now if that helps at all!
I looked around for a while, but I was unable to find a way of programmatically selecting the path such that the widget is in "selected" mode. All the relevant properties are read-only. Am I missing a way of doing this? If not, would you consider adding this?
My use case is that the widget is embedded into a data structure which might already store a path internally. If so, it should be displayed as selected by default.