crahan / ipyfilechooser

Python file chooser widget for use in Jupyter/IPython in conjunction with ipywidgets
MIT License
103 stars 19 forks source link

Creating a new file with an extension not in the allowed extension list #38

Closed giswqs closed 3 years ago

giswqs commented 3 years ago

Thank you for implementing the filter pattern to allow multiple file extensions. It works like a charm! I would like to make a suggestion. If the user creates a new file with a file extension not in the allowed extension list, it is probably better to prompt the user the correct the file extension. If it is something difficult to implement, maybe changing the text color to red rather than the default green color would work.

crahan commented 3 years ago

Sounds good. I'll need to check what would be the easiest option to implement. I'll finish https://github.com/crahan/ipyfilechooser/issues/35 first and release a new version. Then pivot back to this.

crahan commented 3 years ago

The easiest way to solve this is by keeping the select or change button disabled unless the user specifies a filename that matches one of the configured filter patterns. For example, if the filter pattern is set to ['*.txt', '*.png'], only filenames ending in txt or png will enable the button and allow the selection to be saved.

If the user needs to be made aware of this restriction, I'd recommend using the title property or a separate label alongside the filechooser widget to display an additional message with more details.

giswqs commented 3 years ago

Good solution. Thanks.

crahan commented 3 years ago

Thanks for the quick feedback! I'll include this in 0.4.3 together with the top_folder property that restricts navigation to a specific top folder. Should be available in the next day or 2.

crahan commented 3 years ago

Aplogies for the delay on implementing this and the top_folder fix. Unfortunatley, I had to focus on a more pressing matter. I'm picking this back up now.

giswqs commented 3 years ago

No problem. Thank you for your support.

crahan commented 3 years ago

Version 0.4.3 (https://github.com/crahan/ipyfilechooser/releases/tag/v0.4.3) now prevents the chosen filename from being applied when the name does not align with one of the filter_pattern values. PyPi and Conda-forge releases should now be available as well.