Subclassing Python Classes not working for some reason
Dynamic Python binding for Qt Applications
Brought to you by:
florianlink,
marcusbarann
Hi folks,
I'm getting a strange bug. I initialize a base class:
Using:
My base class logs messages to std::out, and this works just fine when I instantiate the base class:
However, I tried subclassing BaseBehavior as such:
And then instantiated the subclass:
But no messages get logged. Very strange.. They DO get logged when I replace my update method with:
This means that the parent class constructor is getting called properly, but that for some reason, the parent class's update routine isn't getting called correctly. Additionally, when I try to call log_info from the parent class as below, I get the same failure to log messages.
Any ideas? If it helps, when I try to use PythonQt's "call" on the update routine to return "super().update(delta_ms)", I get an invalid QVariant returned, instead of the actual output.
Google for super and its problems. Then do direct calls to your base class using BaseClass.xzy(self, arg1, ...). Btw, this has nothing to do with PythonQt itself, it is a pure Python problem.
Okay, I just thought this might be PythonQt-specific, since it runs fine when I run these scripts directly with the same python distribution. Calling the base class directly, as below, also doesn't seem to help me:
Resolved this, the problem was some incorrect import syntax as I was pulling everything into the main module scope.