spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.37k stars 1.62k forks source link

Allow plugins to hook into File > Open #7794

Open jitseniesen opened 6 years ago

jitseniesen commented 6 years ago

This is inspired by spyder-ide/spyder-notebook#134. Users of the spyder-notebook plugin expect to open a notebook using File > Open. At the moment, this causes the notebook to be opened in the editor, which is not so useful. Somehow the notebook plugin (or any other plugin) should be able to indicate that it should be used to open files of a particular type.

Maybe the plugin initialization code should include a call like:

register_file_extension('.ipynb')

When the user opens a file with that extension, Spyder calls the plugin's load() function, similar to Editor.load().

ccordoba12 commented 6 years ago

Some comments about this:

  1. I agree with the register_file_extension name.
  2. This needs to go to to the spyder.api module.
  3. You need to modify the method called open_file from app/mainwindow.py, present here (for now).