Having multiple instance of PythonQt instead singleton instance
Dynamic Python binding for Qt Applications
Brought to you by:
florianlink,
marcusbarann
For some reason I need to have multiple instance of pythonQt in my application but PythonQt does not let to have multiple instance. So I want to know is there any solution for having multiple instance of pythonQt in the application?
Last edit: Edvard 2017-05-16
There can only be one instance of PythonQt and there can only be one Python interpreter(in the same process).
You should use the same PythonQt singleton everywhere and put each part that you want to execute in it's own module, so that the parts don't interfere. There is an Api to create a new module on the PythonQt singleton.
Thanks for your answering, so can you tell me witch API creates a new module?
Last edit: Edvard 2017-05-16
HI Florian, I have a related question. I embed Python/PythonQT in an application - as you can imagine I have a "Run Script" option.
At the moment I am using the Python "C" API PyRun_SimpleString. I would like to (optionally) run the script in a "clean" Python environment - that is with no side-effects of previous runs of other scripts. Is that possible using the PythonQT API.
Yes, just create a new module for each run and execute your code inside of
the module. Alternatively you can also run code inside of a dict, but that
is more complicated because you need to add builtins to the dict.
On Fri, 26 May 2017 at 20:09, Andrewc andrewc8@users.sf.net wrote: