Allow plugins to hook into the IPython console
Hi,
I'm writing a plugin to integrate our (in PySide2/PyQt5) written GUI into Spyder. For this some new features would be nice:
I need to communicate between the gui and the executing ipython kernel. For this I set a startup file to monkeypatch the interaction functions and send spyder messages using get_ipython().kernel.send_spyder_msg("my_msg_type",None, data). I don't see a clean way for a plugin to execute code on a kernel start. But I think this would be a nice feature.
Then I catch these messages by monkeypatching the NameSpaceBrowser._handle_spyder_msg function inside the register_plugin function.
This is kind of messy, it would be nice if I could just implement handlers for my message types.
Did I miss anything which would have made life easier? ;) If there is interest in merging these features I would be willing to implement them :)
Best Christopher
Did I miss anything which would have made life easier? ;)
No, you didn't. We don't provide a public API to interface with the IPython console yet, so I understand things like the ones you're trying to do are really hard.
If there is interest in merging these features I would be willing to implement them
Of course! But you need to do it for Spyder 4 (i.e. against our master branch) because we are not going to implement more new features for Spyder 3.
Please take a look at our api module:
https://github.com/spyder-ide/spyder/tree/master/spyder/api
add an ipythonconsole.py module there and define public functions that allow to extend the spyder_msg functionality.