Here is a typical C + + application framework that is extended using Python. such as Gimp/blender/qgis and so on Linux above the open source software, there are many commercial software also adopted this technology route. However, because of the flexibility of Python, you can use direct-C + + extensions, or scale based on Swig, PyQt, PYTHONQT, resulting in significant differences in implementation. This article describes a writer groping the use of Qt+sip+pyqt+python technology route, is a powerful, mature technology, packaging a relatively small amount of work, and has a commercial-grade development potential.
Most of the Python plugin introduction is about Python itself, because Pytho is a dynamic language, it is not difficult to achieve this, but in many applications, the performance requirements are high, generally need to be implemented in C/S. The Python interpretation engine is then embedded to make it easy for the user to customize the parameters, function extensions and module assembly.
In general, we encapsulate the C + + class of the main program through SIP, which can then be called directly through Python in the Python shell.
The Python console is then integrated into the main program window to control the operation of the main window directly through Python. There are two things to do here, one is to embed the console window in the main window, and the other is to pass the object handle of the main program to the Python interpreter environment. If initialized by Python, the object of the main window and the object of the interpreter are not the same and cannot be manipulated with each other. Of course, the main program can also be shared through global static objects, but it is not recommended to affect the scalability of subsequent programs.
(not to be continued)
C + + extension framework based on Python plugin