4.8.2 C++/Python interface

MathGL provides the interface to a set of languages via SWIG library. Some of these languages support classes. The typical example is Python – which is named in this chapter’s title. Exactly the same classes are used for high-level C++ API. Its feature is using only inline member-functions what make high-level API to be independent on compiler even for binary build.

There are 3 main classes in:

To use Python classes just execute ‘import mathgl’. The simplest example will be:

import mathgl
a=mathgl.mglGraph()
a.Box()
a.WritePNG("test.png")

Alternatively you can import all classes from mathgl module and easily access MathGL classes like this:

from mathgl import *
a=mglGraph()
a.Box()
a.WritePNG("test.png")

This becomes useful if you create many mglData objects, for example.