File picker widget for the host filesystem in Jupyter.
Project description
Jupyter Host File Picker
Jupyter widget for picking files on the host machine.
This widget allows users to select files from the machine that Jupyter is running on. This can be the user's own machine in the case of a local Jupyter session, or it can be a remote system when using Jupyter Hub. In contrast, ipywidgets.FileUpload can only select files on the user machine.
Installation
Install with pip:
python -m pip install jupyter_host_file_picker
or with uv:
uv add jupyter_host_file_picker
Usage
See the example notebook for a complete usage example.
The HostFilePicker class is a dialog with a file browser on the host machine.
You can create and display a HostFilePicker just like any other
Jupyter widget:
from jupyter_host_file_picker import HostFilePicker
picker = HostFilePicker()
# At the end of a cell:
picker
In the dialog, navigate folders by double-clicking on a folder or by single-clicking and using the 'Open' button. Similarly, select a file by double-clicking or by using the 'Select' button.
Accessing the selected file
The selected file path is stored in
picker.selected
This attribute is a list of Path objects.
[!NOTE] Displaying the file picker will not block the Python kernel. So the
selectedlist is empty until the user selects a file.
Callback
Alternatively to the selected attribute, you can register an observer function
that will be called whenever the user selects a file:
def print_selected(change):
print("Selected file", change["new"])
picker.observe(print_selected, names="selected")
Note that this will only print to the Jupyter log console.
Example with button and text field
Here is a more extensive example that uses a button to open the dialog and a text field to display the selected file:
import os
from pathlib import Path
from typing import Any
from IPython.display import display
from ipywidgets import Button, HBox, Layout, Output, Text
from jupyter_host_file_picker import HostFilePicker
selected_text = Text(layout=Layout(width="100%"))
browse_button = Button(description="Browse", icon="folder-open")
dialog_output = Output(layout=Layout(display="none"))
def sync_selected(change: dict[str, Any]) -> None:
# Insert the selected path into the text field.
selected: list[Path] = change["new"]
if selected:
path = selected[0] # For now, there always is only one path.
selected_text.value = os.fspath(path)
def browse_files(_: Button) -> None:
# Open a dialog when the button is clicked.
with dialog_output: # Use the Output widget as a display context.
dialog_output.clear_output() # Remove old dialog, if any.
picker = HostFilePicker()
picker.observe(sync_selected, names="selected")
display(picker)
browse_button.on_click(browse_files)
HBox([selected_text, browse_button, dialog_output])
We open the dialog from a callback of the button.
This callback does not have a display context,
and so we cannot simply show the dialog using display(picker).
Instead, we use a dedicated Output widget to provide the necessary display context.
(This widget hat Layout(display="none") because it does not need to be visible itself;
it only provides access to the HTML document.)
Development
Requirements
Install the following:
These tools manage all dependencies and build the package.
Run development build
The first time you clone the repository, install JavaScript dependencies using
npm install
Run the following to build the TypeScript code.
This will automatically rebuild after any changes in the js folder.
npm run dev
Then, launch Jupyter with the example notebook:
uv run jupyter lab example.ipynb
Uncomment the first code cell to enable hot-reloading of JavaScript and CSS code. If you make changes to the Python code, you need to restart the kernel.
Make a release
To make a release, create a new release on GitHub and select a tag name according to the calendar versioning scheme. GitHub actions will do the rest; you only have to approve the deployment to PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jupyter_host_file_picker-26.2.1.tar.gz.
File metadata
- Download URL: jupyter_host_file_picker-26.2.1.tar.gz
- Upload date:
- Size: 97.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61e519859423c0d394eefd5c472b490ac66e30397f22f012f95b0dda43c45318
|
|
| MD5 |
6a7bbf24609c441e621fbd18d6d2ab30
|
|
| BLAKE2b-256 |
d8280a649be99b27d5728545d48b88b87511821efb96e5b003876b2479a02d68
|
Provenance
The following attestation bundles were made for jupyter_host_file_picker-26.2.1.tar.gz:
Publisher:
release.yml on jl-wynen/jupyter-host-file-picker
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jupyter_host_file_picker-26.2.1.tar.gz -
Subject digest:
61e519859423c0d394eefd5c472b490ac66e30397f22f012f95b0dda43c45318 - Sigstore transparency entry: 908067808
- Sigstore integration time:
-
Permalink:
jl-wynen/jupyter-host-file-picker@877536c5955f6d30f3ffe6fbc0a695e089bd0c82 -
Branch / Tag:
refs/tags/26.2.1 - Owner: https://github.com/jl-wynen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@877536c5955f6d30f3ffe6fbc0a695e089bd0c82 -
Trigger Event:
release
-
Statement type:
File details
Details for the file jupyter_host_file_picker-26.2.1-py3-none-any.whl.
File metadata
- Download URL: jupyter_host_file_picker-26.2.1-py3-none-any.whl
- Upload date:
- Size: 98.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c9044c121480cd9f3a61fd62d02cc917874ef66a1e3b6f22ebfbd3b3aaa7176
|
|
| MD5 |
07f3fccd6dfabce40a35ae19c85cbd24
|
|
| BLAKE2b-256 |
b05ee84a63e0bb11589edf5d0a31804f5891b43f3277c53d5c28aafbac4affba
|
Provenance
The following attestation bundles were made for jupyter_host_file_picker-26.2.1-py3-none-any.whl:
Publisher:
release.yml on jl-wynen/jupyter-host-file-picker
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jupyter_host_file_picker-26.2.1-py3-none-any.whl -
Subject digest:
6c9044c121480cd9f3a61fd62d02cc917874ef66a1e3b6f22ebfbd3b3aaa7176 - Sigstore transparency entry: 908067816
- Sigstore integration time:
-
Permalink:
jl-wynen/jupyter-host-file-picker@877536c5955f6d30f3ffe6fbc0a695e089bd0c82 -
Branch / Tag:
refs/tags/26.2.1 - Owner: https://github.com/jl-wynen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@877536c5955f6d30f3ffe6fbc0a695e089bd0c82 -
Trigger Event:
release
-
Statement type: