How to run script in a new PythonQT 3.1 "module"
Dynamic Python binding for Qt Applications
Brought to you by:
florianlink,
marcusbarann
PythonQT 3.1, Python 3.6.1
We want to run our python scripts in a new "module" each time so there is no variable pollution from each script run.
As per my code below.
This code works fine for , say , a "hello world" script. But more complicated scripts such as, say, a PyQt5 script just fail.
What do you mean by "just fail"? People invented error printing and debuggers to find out more details than just failing...
Florian, I spent a lot of time looking at this, and when I said "just fail", I had already significant time in the debugger trying to locate the failure. For example, with PYTHONVERBOSE=3, and testing by running a Pyqt5 script, I see the all expected modules being loaded but no PyQT UI appears. There is no obvious place to put a breakpoint, nor is there a crash to place to start debuggging. I suppose my question boils down to simple "would you expect the above code to work or am I missing something obviuous"
Hm, I never tried running PyQt5 scripts with PyQt bindings in PythonQt, since PythonQt provides its own wrappers for Qt. Typically you would port a PyQt5 script to PythonQt by changing the imports to PythonQt.QtCore etc. and adapt the source where PythonQt and PyQt are different.
Sorry to confuse the issue with mentioning PyQT5 - PyQT5 scripts work just fine when run from the mainModule. They happily co-exist with PythonQT
I can't even get "HelloWorld" to run in my example above in a "new" context/module. I just feel I am missing something completely obvious. For example , do I need to set up new sys.path 'again' for the new module if I changed it for the mainModule?
No, I don't think you need to do any additional things on a new module, sys.path is global.
Maybe the unique module creation has a problem on Python 3, I think I never tested that after porting.
We are switching to Python 3 in my company soon, so PythonQt will get hardened regarding Python 3 support.