代码之家  ›  专栏  ›  技术社区  ›  user1592380

Ipywidget选择框未打开

  •  1
  • user1592380  · 技术社区  · 2 年前

    enter image description here

    我有一个jupyter笔记本,我正在运行leafmap。我正在尝试添加一个文件选择器,它将打开一个小部件来选择本地文件。我在一个单元格中有以下内容:

    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])
    

    运行单元格时,不会打开任何选择框。我做错了什么?

    1 回复  |  直到 2 年前
        1
  •  1
  •   Jonny Henly Anton Gogolev    2 年前

    添加 display(source_widget) 到单元格的末尾。

    enter image description here

    推荐文章