[Interest] Qt program scripting with PySide2

Filippo Rusconi listes.rusconi at laposte.net
Wed Sep 2 11:32:49 CEST 2020


Greetings, Fellow Developers,

regarding the message I sent about scripting in Qt, for which I received, some
enlightening answers, I would like to deepen my understanding about PySide2 (see
below).

> Date: Thu, 18 Jun 2020 19:05:15 +0200
> From: Cristián Maureira-Fredes <Cristian.Maureira-Fredes at qt.io>
> To: interest at qt-project.org
> Subject: Re: [Interest] Qt scripting with JavaScript
> 
> 
> 
> On 6/18/20 11:35 AM, Filippo Rusconi via Interest wrote:
> > Greetings, Fellow Developers,
> > [snip]
> > Script-wise, how about using Python to make my program scriptable? Is
> > PySide
> > something that would match the requirement? Has anybody tried both Qt
> > Script and
> > Python ? If so, what lessons were learnt ?
> 
> Hey Filippo,
> 
> we have an example called 'scriptableapplication',
> which it seems is the requirement you have.
> The scenario is a Qt/C++ desktop application,
> from which we embed a Python interpreter,
> so you can modify the application with Python scripts.
> 
> Source:
> https://code.qt.io/cgit/pyside/pyside-setup.git/tree/examples/scriptableapplication
> 
> If you want to check an animation of how that looks like:
> https://www.qt.io/blog/2019/08/19/technical-vision-qt-python
> (check the GIF under "Embedding Python")
> 
> If you want to watch a couple of minutes
> from the last webinar on that topic, check this video
> https://www.youtube.com/watch?v=Vb1dbLQafyM&t=27m06s
> (notice the time)
> That's an extension of the same example,
> but implementing a plugin system on top.
> 
> I hope that helps you,

Thank you so much, Cristián, for your answer.

I have looked into the documents that you referred to above and found them very
exciting. I have a question, though: 

Logically, all the examples are citing the creation of Python bindings to C++
Qt-based libraries. 

In my GUI software, I use one public library that I co-develop with a colleague,
and making Python bindings to it appears to be perfectly feasible. The point is
that my program (executable GUI binary) is written in C++ and not using PySide2.
How can I make the features in the GUI binary's code accessible to Python users?
That is, can bindings be created not only for libs but also for executable
binaries?  Or, in other words, how can I take control of the C++-based program
using Python? If this is no possible, then what should be the course of
development? Switch all the GUI code to PySide2, put any non-GUI code in a
private lib to which Python bindings would be created ?

Sorry for these layman questions,

Most sincerely,

Filippo

-- 

⢀⣴⠾⠻⢶⣦⠀  Filippo Rusconi, PhD
⣾⠁⢠⠒⠀⣿⡁   Research scientist at CNRS
⢿⡄⠘⠷⠚⠋⠀   Debian Developer
⠈⠳⣄⠀⠀⠀⠀  http://msxpertsuite.org
           http://www.debian.org



More information about the Interest mailing list