[PyQt] Python Threads do not work when QWidget is extracted from sip.unwrapinstance

Phil Thompson phil at riverbankcomputing.com
Mon Jan 18 12:34:53 GMT 2016


On 18 Jan 2016, at 11:40 am, Deepak Hosamane <Deepak.Hosamane at lntebg.com> wrote:
> 
> Hi,
>  
> I am trying to create an application which can simply embed PyQt5 scripts as QWidgets into my C++ Qt-GUI( in Windows ) application.
> I was successful in embedding the scripts in my application but the threads written inside the Python scripts simply won't work.
> After having read a few articles on GIL interpreter locks, it looked to me like they are not applicable in my case as these python threads are not to be called explicitly by the C++ application.
>  
> Could someone kindly guide me on what could be done to enable these Python threads in my C++ Application.
> Any help would be greatly appreciated. 
>  
> Sample code has been attached for reference.( To run the executable just place the Screen.py file where the Executable is generated ... )

The GIL is always applicable. It can be very difficult to anticipate when Python code or C++ will be run especially when you have Python reimplementations of C++ virtuals.

Phil



More information about the PyQt mailing list