Embedding Spyder into C++ QT5 app

342 views
Skip to first unread message

AndrewC

unread,
Feb 6, 2017, 5:08:53 AM2/6/17
to spyder
Hi,

I have a QT 5.7 app (C++, Desktop Windows) that has an embedded python 3.5 interpreter and console. That is, the app links to and uses the  python3 DLLs/API. I can launch PyQT5 python scripts from with the app (the scripts need a slight modification to use my QApplication.instance(), thats about it). It works surprisingly well.

I am looking at the possibility of embedding the  Spyder IDE ( or parts thereof) as way to add Python editing/debugging within my GUI.

It seems that embedding Spyder into an existing C++ application pops up now and then, but links to examples seem broken.

Am I wasting my time? 

Thanks

Carlos Córdoba

unread,
Feb 6, 2017, 5:13:54 AM2/6/17
to spyd...@googlegroups.com

Hi,

If you can use PyQt5 in your application, you can certainly use the Spyder widgets (placed under spyder/widgets in our repo), which are more or less independent of the application.

You can’t do the same with our plugins though because they expect our config system and be placed in the Spyder window to run.

Cheers,
Carlos

El 04/02/17 a las 14:41, AndrewC escribió:

--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.
To post to this group, send email to spyd...@googlegroups.com.
Visit this group at https://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.

AndrewC

unread,
Feb 6, 2017, 6:53:49 PM2/6/17
to spyder
Hi Carlos,
Thanks for your reply.
I was going to ask for examples but I see that the widgets come with a "test" function.
Excellent!

Andrew

AndrewC

unread,
Feb 7, 2017, 2:19:27 PM2/7/17
to spyder
Hi Carlos,
I have been experimenting with this and found the following.

From a 'standard' python prompt (outside of my application)
>>> import spyder.widgets.editor as spyed
>>> spyed.test()
Works exactly as expected and puts up a very nice Spyder editor widget.
But I notice that 4 copies of python.exe are launched in the background - one for each test.load()

So to run  the test() function in editor.py from within my QT app I made two modifications ( typical for any PyQT5 'apps')
Comment out these lines ( because a QApplication is already running)

#app = qapplication(test_time=8)
#sys.exit(app.exec_())

When I run the test, multiple copies of my application .EXE are launched in the background as a separate process for every test.load, just as per the pure python example.
Clearly this is not what I want to happen! Is there some way to make this run 'in process'.






On Monday, February 6, 2017 at 2:13:54 AM UTC-8, Carlos Córdoba wrote:
Reply all
Reply to author
Forward
0 new messages