I have monitored the growing interest of Python over the past years, especially within the scientific field. I am writing a scientific Windows application in C++ and would like to embed python to allow for extensions to my program; analysis, visualization etc.
Some of my colleagues have worked with linking directly to the <python.h> for executing a Python script, and another team making an extension DLL to Python for accessing and exchanging data with their application trough pipes. Both seems to work fine, - however.
I found the interactive size of Python and especially the JupyterLite features extremely attractive. But my problem is that I am from the classical Windows world and not familiar with the terminologies and code in the Python world. I found JupyterLite and will refer to this here, but if this is wrong please correct me. My inspiration is the Python Shell in ParaView.
What I ideally want to achieve is:
ā¢ In a window/view/form in my C++ Windows application I want to run a session of JupyterLite.
ā¢ From this I should have access to all the Python features including packages like numpy, matlabplot etc.
ā¢ I should then be able to exchange data between my application and the interactive Python JupyterLite code.
ā¢ I should be able to visualize data from my application in the JupyterLite and return calculated data back to my application.
Here is what I overall imagine:
ā¢ I setup JupyterLite on a localhost web server.
Where can I configure all Python modules?
Alternatively running my own server if that is possible?
ā¢ I create a WebView2 window in my application to show the JupyterLite UI.
I configure the JupyterLite UI to be minimal (REPL) mode, removing as many of the browser menus, toolbars etc.
ā¢ I write an extension DLL for interacting with my application, calling methods for exchanging data.
However a lot of questions arises:
ā¢ Can I distribute Python/JupyterLite with my application?
ā¢ Is Python a part of JupyterLite?
ā¢ Can I run JupyterLite without an internet connection?
ā¢ Can I run JupyterLite as a localhost web server?
ā¢ Can I customize the JupyterLite UI to have a minimal UI, theme color support, context menu control?
ā¢ Can I write an extension DLL to JupyterLite that can communicate with my application when it runs in a browser?
I really hope someone find time to answer my questions, thanks cpede.
OK, I have to realize that there is no interest in answering this kind of question, since I have asked this in various Python forums in the last many years. So, I have to assume that the is a good reason for that, and one obvious reason is that Iām going in a wrong direction. Even it seems obvious for me to embed Python/JupyterLite into my application it is probably not the preferred way of exchanging data between a Windows application and Python. So I will therefore ask this question in a new thread:
How would a real Python user like to exchange data with a Windows application?
https://discourse.jupyter.org/t/how-would-a-real-python-user-like-to-exchange-data-with-a-windows-application/25221?u=cpede
Maybe you want to take a step back and simplify the problem (or solution, if you will) at hand.
I never embedded JupyterLite nor do I plan to do it, but AFAIU the Jupyter in there is running on a different stack, inside a browser; the Python interpreter there is not your good-old CPython you usually install. Hopefully the following pages can give you a better idea on extending and customizing Lite:
- Create a JupyterLite archive that can be used offline ā JupyterLite 0.3.0 documentation
- Communication between a host page and a JupyterLite instance running in an IFrame ā JupyterLite 0.3.0 documentation
On the starting point of simplifying your problem/solution, maybe you want to embed the Qt Console and see how that works?
Thank you for your answer. I understand that Jupyter runs in a browser or on a server, why embedding in a Windows application does not make sense.
But what I want is the nice interactive and graphing features that Jupiter allows for in the editor.
So, maybe my question is:
How do I embed an editor in a windows application that allows for Interactive and Graphing features like in Jupyter?
It should run locally on the PC with the installed version of Python. what I probably want is to embed the editor with all the capabilities.