Widgets not displaying

Please read and revise your post based on Getting good answers to your questions. Pay particular attention to the the information about making a minimal reproducible example (MRE) and provide one. Specifically, if your issue is with ipyfilechooser then make a new notebook and run only enough code to get the issue you are facing. (I suspect it will be only a few lines; however, you have way too much stuff here making it nowhere near an MRE.) Then supply that code block here formatted to be readable with syntax highlighting and useable. To help with that, see about ‘block code formatting’ and ’ Automatic code styling’ here.

Update:
I think the minimal MRE you may be looking for is below in this demo of using ipyfilechooser where it works with ipywidgets properly installed:

  1. Click ‘launch binder’ here to start a session (or just click here to launch a Jupyter session directly), then when the notebook interface opens, click the Jupyter logo in the upper left, and then change the end of the URL from /tree to /lab. That will change the interface to the JupyterLab interface in this session.

  2. Open a new notebook.

  3. Run in a cell the following:

    %pip install ipyfilechooser
    
  4. Then restart the kernel and refresh the browser page.

  5. Then in a new cell run the following code pared down to the pertinent code from your posted code:

    from ipyfilechooser import FileChooser
    from pathlib import Path
    path = Path.cwd()
    fc = FileChooser(path)
    display(fc)
    
  6. Use the widget to select a file.

  7. Finally, to demonstrate a selection has been made, in the next cell run the following:

    # Then from Usage at https://github.com/crahan/ipyfilechooser#usage
    # Print the selected path, filename, or both
    print(fc.selected_path)
    print(fc.selected_filename)
    print(fc.selected)
    

That should give you a place to see how it works and compare the behavior with your system.

On your system, I suspect after opening Jupyter, you just need to do steps #5 & #6 in a new notebook and I suspect you’ll get the error you reported. Unless restarting things fixed it in the meantime.

1 Like