Package: ipyfilechooser
ipyfilechooserA simple Python file chooser widget for use in Jupyter/IPython in conjunction with ipywidgets. The selected path and file are available via.selected_pathand.selected_filenamerespectvely or as a single combined filepath via.selected. The dialog can be reset to its default path and filename by using.reset().When a typed filename matches an existing file entry in the current folder the entry will be highlighted. If a typed filename matches a folder entry in the current view the selection button is disabled ensure the user is aware of the match. To select a folder simply leave the filename field empty.To emphasize the risk of overwriting existing files, the selected filepath is displayed in green if the file does not exist and orange if it does.UsagefromipyfilechooserimportFileChooser# Create and display a FileChooser widgetfc=FileChooser('/Users/crahan/FC demo')display(fc)# Print the selected path, filename, or bothprint(fc.selected_path)print(fc.selected_filename)print(fc.selected)# Change defaults and reset the dialogfc.default_path='/Users/crahan/'fc.default_filename='output.txt'fc.reset()# Shorthand resetfc.reset(path='/Users/crahan/',filename='output.txt')# Restrict navigation to /Usersfc.sandbox_path='/Users'# Change hidden filesfc.show_hidden=True# Customize dir iconfc.dir_icon='/'fc.dir_icon_append=True# Switch to folder-only modefc.show_only_dirs=True# Set a file filter pattern (uses https://docs.python.org/3/library/fnmatch.html)fc.filter_pattern='*.txt'# Set multiple file filter patterns (uses https://docs.python.org/3/library/fnmatch.html)fc.filter_pattern=['*.jpg','*.png']# Change the title (use '' to hide)fc.title='<b>FileChooser title</b>'# Sample callback functiondefchange_title(chooser):chooser.title='<b>Callback function executed</b>'# Register callback functionfc.register_callback(change_title)Functions and propertiesfc.reset()fc.refresh()fc.register_callback(function_name)fc.show_hiddenfc.dir_iconfc.dir_icon_appendfc.show_only_dirsfc.rowsfc.titlefc.filter_patternfc.defaultfc.default_pathfc.default_filenamefc.sandbox_pathfc.valuefc.selectedfc.selected_pathfc.selected_filenameScreenshotsClosed vs open dialogExisting vs new file selectionQuick navigation dropdownUse folder iconsRestrict navigationRelease notes0.6.0The ability to restrict file browsing to asandbox_pathfolder has finally been added!Filenames can not contain path separator characters or parent folder strings (i.e., '..')use_dir_iconshas been replaced withdir_iconwhich allows for customizing the folder icondir_icon_appendcan now be used to put the folder icon before or after the folder nameBetter error handling withParentPathError,InvalidPathError, andInvalidFileNameErrorBetter and more consistent handling of Windows drive letters and pathsFix bug where resetting the filechooser would not reenable the select/change buttonProperly handle folder permission errors by raising a warning0.5.0Widget width is now configurable using thelayoutproperty and aLayoutobjectFolder paths are now normalized usingos.path.normpathto properly handle '/' and '\' on WindowsThe widget now supports thevalueproperty to align with other widget typesThe label showing the selected value now reflows the text to new lines as required (and shows a scrollbar if the value is too long)Buttons now have a minimum width to ensure their text is always visible, regardless of widget width0.4.4Added typing hints (@Mandroide)Updated max line length check from 90 to 120 charactersFixedfilter_patternvalues not being treated as case-insensitiveGeneral code cleanup0.4.3Prevent applying the selected value if the filename doesn't match one of thefilter_patternvalues0.4.2Added ability to specify a list offnmatchpattern strings forfilter_pattern0.4.1Fixed issue withselect_defaultnot being applied onreset0.4.0Option added to specify a file filter (@andriykorchak)Add support forValueWidgetandget_interact_value()Updated sample notebook with filter exampleUpdated Development Status to Production/Stable0.3.5Option added to only display folders (@andriykorchak)0.3.4Option added to display folder icons (@ptooley)0.3.3Option added to addselfas an argument to the callback function (@ptooley)0.3.2ReturnNoneif file is not selected (@danjjl)0.3.1Option to register a callback function (register_callback(function_name))0.3.0Ability to select a folderSupport for Windows drive lettersOption to use the defaults as the selected value0.2.0First public release