Search code examples
pythonjupyter-notebookipywidgets

Ipywidget selection box not opening


enter image description here

I have a jupyter notebook and I'm running leafmap. I'm trying to add a filepicker that will open up a widget to select a local file. I have the following in a cell:

import ipywidgets as widgets
from ipyfilechooser import FileChooser
import os

padding = "0px 0px 0px 5px"
style = {"description_width": "initial"}

tool_output = widgets.Output(
    layout=widgets.Layout(max_height="150px", max_width="500px", overflow="auto")
)

file_type = widgets.ToggleButtons(
    options=["GeoTIFF", "COG", "STAC", "Microsoft"],
    tooltips=[
        "Open a local GeoTIFF file",
        "Open a remote COG file",
        "Open a remote STAC item",
        "Create COG from Microsoft Planetary Computer",
    ],
)
file_type.style.button_width = "110px"

file_chooser = FileChooser(
    os.getcwd(), sandbox_path=m.sandbox_path, layout=widgets.Layout(width="454px")
)
file_chooser.filter_pattern = ["*.tif", "*.tiff"]
file_chooser.use_dir_icons = True

source_widget = widgets.VBox([file_chooser])

When I run the cell, no selection box opens. What am I doing wrong?


Solution

  • Add display(source_widget) to the end of the cell.

    enter image description here