Reputation: 41
How to use pyqt classes in Cython(.pyx file)?
In fact, how can pyqt classes be inherited in cython classes?
thank you
Upvotes: 1
Views: 566
Reputation: 30889
All Python code should be valid Cython code (there are bugs, so this isn't quite true, but it's close). Therefore Python code using PyQt should work as it is under Cython and if it doesn't then you should report it to the Cython bugtracker. However, in the past people have reported problems because PyQt uses multiple threads but Cython does not release the GIL regularly. Therefore you might find that your application hangs and it is not possible to combine PyQt and Cython.
Cython has no special access to PyQt classes therefore you should not cdef
them - just treat them as normal Python variables.
Because of this lack of special access you cannot inherit from them in a cdef class
. However they work fine when you inherit from in a normal class.
In general there is no benefit to trying to set cdef
types for regular Python objects (including PyQt classes); just write the code as if it was Python.
Upvotes: 3