[Interest] Qt program scripting with PySide2 (follow-up)

Filippo Rusconi listes.rusconi at laposte.net
Thu Sep 3 14:40:31 CEST 2020


Greetings, Fellow Developers,

[I am using the digest method for list mails delivery, so I cannot reply cleanly
to a defined message ]

> Subject: Re: [Interest] Qt program scripting with PySide2
> 
> On 9/2/20 11:32 AM, Filippo Rusconi via Interest wrote:
> > Greetings, Fellow Developers,
> > 
> > [snip]
> >>
> >> 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.
> 
> The ones I included yes,
> but we do have cases with non-Qt projects,
> for example:
> 
> https://code.qt.io/cgit/pyside/pyside-setup.git/tree/examples/samplebinding?h=5.15
> 
> which has this blog post associated:
> https://www.qt.io/blog/2018/05/31/write-python-bindings
> 
> If you would like to see and even minimal example
> on how to generate bindings, you can check this 'hello world'
> example from the Virtual Tech Summit 2020:
> 
> http://maureira.xyz/talks/qt/qtforpython_vts2020/code/example_module.html

Thank you, Cristian for these pointers.

Yes, I have looked into them and definitely I will try the Qt
for Python journey.

I have indeed followed the install instructions, at
https://doc.qt.io/qtforpython/gettingstarted-linux.html.

Using a virtual environment I could perform all the steps on my Debian box,
until bulding where an error was encountered. Where can I find a place to report
that error and try to resolve it with the help of gurus ? Maybe #qt-pyside on
freenode ?

> > 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 ?
> 
> I guess with the previous links you will be able to expose C++ code
> to Python, independent of the libraries you use, however keep in mind
> that if you want to expose a specific aspect of the library you wrote,
> you might need bindings for it too.
> 
> You cannot create bindings for a specific executable,
> but you can expose 'something' from what's forming that executable
> to Python, and create bindings for it, for example, on the 
> 'scriptableapplication' example, we expose only the 'MainWindow' class
> to Python, that's why that can provide control of the C++ application,
> although, since that depended on a 'QMainWindow' which had bindings
> for Python, it was simpler. If something that you want to expose to 
> Python, does not have a plain C++ type, that type will require 
> additional bindings.
  
Understood.

> If I may ask, what are you using for your GUI related code?

Sure, I have been writing Qt-based software for a long time. My GUI code is
Qt-based.  For all the line and heat map plots that I need to display, I use the
wonderful library called QCustomPlot (see https://www.qcustomplot.com/, GPL
software by Emanuel Eichhammer).

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