What does FreeCAD use to embedded Python to C++

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
haonk
Posts: 13
Joined: Wed Jun 05, 2019 3:11 am
Location: VietNam

What does FreeCAD use to embedded Python to C++

Postby haonk » Fri Jul 19, 2019 4:54 am

Hi!
i am new in Python and C++, i wanna improving FreeCAD source code. But i do not know how did it embedded Python into C++.
I am searching in Google and find something: pybind11, CPython and Boost.Python. So, what does we use for FreeCAD? i wanna know to learning, please help me!
wmayer
Site Admin
Posts: 14423
Joined: Thu Feb 19, 2009 10:32 am

Re: What does FreeCAD use to embedded Python to C++

Postby wmayer » Fri Jul 19, 2019 8:55 am

haonk wrote:
Fri Jul 19, 2019 4:54 am
Hi!
i am new in Python and C++, i wanna improving FreeCAD source code. But i do not know how did it embedded Python into C++.
I am searching in Google and find something: pybind11, CPython and Boost.Python. So, what does we use for FreeCAD? i wanna know to learning, please help me!
We use several Python binding libraries. boost.python or alternatively pybind11 is used for the flatmesh and area modules. But for the vast majority we use our own wrapper. For a class to be wrapped an XML file must be provided and an *Imp.cpp file where the C++ <-> Python stuff is done. The framework is very close to how it's described in the section of embedding in the Python documentation.
haonk
Posts: 13
Joined: Wed Jun 05, 2019 3:11 am
Location: VietNam

Re: What does FreeCAD use to embedded Python to C++

Postby haonk » Mon Jul 22, 2019 6:39 am

wmayer wrote:
Fri Jul 19, 2019 8:55 am
We use several Python binding libraries. boost.python or alternatively pybind11 is used for the flatmesh and area modules. But for the vast majority we use our own wrapper. For a class to be wrapped an XML file must be provided and an *Imp.cpp file where the C++ <-> Python stuff is done. The framework is very close to how it's described in the section of embedding in the Python documentation.
And how about GUI? what does we use for FreeCAD? i see PySide, PyQt in FreeCAD project
Where should i start?
wmayer
Site Admin
Posts: 14423
Joined: Thu Feb 19, 2009 10:32 am

Re: What does FreeCAD use to embedded Python to C++

Postby wmayer » Mon Jul 22, 2019 9:00 am

And how about GUI? what does we use for FreeCAD?
The above mentioned libraries are used to write your own Python wrappers for C++ classes while PySide is an already 3rd party wrapper for Qt which we can use as is.
haonk
Posts: 13
Joined: Wed Jun 05, 2019 3:11 am
Location: VietNam

Re: What does FreeCAD use to embedded Python to C++

Postby haonk » Wed Jul 31, 2019 1:30 am

wmayer wrote:
Mon Jul 22, 2019 9:00 am
The above mentioned libraries are used to write your own Python wrappers for C++ classes while PySide is an already 3rd party wrapper for Qt which we can use as is.
Thanks!!! but i have an question!
Just like Arch or Draft workbenches, Can I using only Python to create a new module? or i have to use both if i want a perfectly module?.
I didn't know about C++
chrisb
Posts: 16836
Joined: Tue Mar 17, 2015 9:14 am

Re: What does FreeCAD use to embedded Python to C++

Postby chrisb » Wed Jul 31, 2019 5:12 am

You may have a look at the several addon workbenches to see how they build the GUI and interface with FreeCAD structures.