kopia lustrzana https://github.com/crahan/ipyfilechooser
Add support for root_path parameter
rodzic
3f5c14c92c
commit
fa44a64200
|
@ -23,6 +23,7 @@ class FileChooser(VBox, ValueWidget):
|
|||
use_dir_icons: bool = False,
|
||||
show_only_dirs: bool = False,
|
||||
filter_pattern: Optional[Sequence[str]] = None,
|
||||
root_path: str = '',
|
||||
layout: Layout = Layout(width='500px'),
|
||||
**kwargs):
|
||||
"""Initialize FileChooser object."""
|
||||
|
@ -37,6 +38,7 @@ class FileChooser(VBox, ValueWidget):
|
|||
self._use_dir_icons = use_dir_icons
|
||||
self._show_only_dirs = show_only_dirs
|
||||
self._filter_pattern = filter_pattern
|
||||
self._root_path = root_path
|
||||
self._callback: Optional[Callable] = None
|
||||
|
||||
# Widgets
|
||||
|
@ -160,7 +162,7 @@ class FileChooser(VBox, ValueWidget):
|
|||
filename = ''
|
||||
|
||||
# Set form values
|
||||
self._pathlist.options = get_subpaths(path)
|
||||
self._pathlist.options = get_subpaths(path, self._root_path)
|
||||
self._pathlist.value = path
|
||||
self._filename.value = filename
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ def prepend_dir_icons(dir_list: Iterable[str]) -> List[str]:
|
|||
|
||||
|
||||
def get_drive_letters(path: str) -> List[str]:
|
||||
"""Get drive letters."""
|
||||
"""Get all drive letters minus the drive used in path."""
|
||||
if sys.platform == 'win32':
|
||||
# Check if path uses upper or lowercase drive letters
|
||||
chars = string.ascii_lowercase
|
||||
|
|
Ładowanie…
Reference in New Issue