Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to open in extra dialog window? #31

Open
stefaneidelloth opened this issue Nov 2, 2020 · 3 comments
Open

How to open in extra dialog window? #31

stefaneidelloth opened this issue Nov 2, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@stefaneidelloth
Copy link

Currently the file selection is shown in the cell output area.

How can I show the file selection as an extra popup dialog window?

(I would like to reuse the functionality of ipyfilechooser in a JupyterLab extension.)

@crahan
Copy link
Owner

crahan commented Nov 5, 2020

I'm not sure how that would be accomplished, but I'll dig into it a little more.

@crahan crahan added the enhancement New feature or request label Nov 5, 2020
@crahan crahan self-assigned this Nov 5, 2020
@stefaneidelloth
Copy link
Author

Thank you. As an alternative I found the FileDialog helpers.
https://jupyterlab.readthedocs.io/en/stable/developer/ui_helpers.html

var { FileDialog } = require('@jupyterlab/filebrowser');
var { IDocumentManager } = require ('@jupyterlab/docmanager');

...

async browseFilePath(initialDirectory, initialFile){

		var FileDialog = this.__dependencies['FileDialog'];
		var documentManager = this.__dependencies['documentManager'];

		const dialog = FileDialog.getOpenFiles({manager: documentManager});
	    const result = await dialog;
		if(result.button.accept){
		  let files = result.value;
		  return files[0].path.trim();
		}
		return ''; 
    }	

   
    async browseDirectoryPath(initialDirectory){   	
		var FileDialog = this.__dependencies['FileDialog'];
		var documentManager = this.__dependencies['documentManager'];

        //logs some error to the console due to a Jupyterlab bug
        //also see
        //https://github.com/jupyterlab/jupyterlab/issues/9263
		const dialog = FileDialog.getExistingDirectory({manager: documentManager});
	    const result = await dialog;
		if(result.button.accept){
		  let folders = result.value;
		  return folders[0].path.trim();
		}
		return ''; 	
    }

@crahan
Copy link
Owner

crahan commented Nov 13, 2020

Thanks for the link. Good to know you were able to find a workaround. My goal is to keep ipyfilechooser compatible with both Jupyter Notebook and Lab so I'll keep digging some more to see if there's a possible solution that would work in both those cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants