Python and GeoGebra objects
When code such as
p1 = Point(3, 4)
p1.size = 8
runs, the first line of code causes two objects to be created:
- a GeoGebra
Point is created within GeoGebra and added to the GeoGebra construction, and
- a Python
Point is created on the Python side to refer to that GeoGebra
Point; the Python variablep1refers to this Python object.
The second line of code then sets the size property of the
Python Point object referred to by p1.
Internally, this then sets the size of the underlying GeoGebra
Point.
In this way, the Python Point objects acts as a wrapper
around the GeoGebra Point object.
Constructors
In general, constructors for wrapper classes are the same as the ways
you can call the corresponding GeoGebra command. For example, the
different ways to construct a Ellipse correspond to the
different ways you can use the GeoGebra Ellipse() command.
Object lifetimes and accessibility
Currently, GeoGebra objects cannot be deleted from the construction,
although they can be hidden, by setting their is_visible
property to False.
The Python wrapper objects, however, can become inaccessible (and so effectively no longer exist) if no references to them remain. For example, the code
p1 = Point(3, 4)
Point(5, 6)
creates two GeoGebra Point objects, each with a wrapper Python
Point object. However, the Python Point
wrapping the GeoGebra Point at (5, 6) has no variable
referring to it. The underlying GeoGebra Point continues to
exist in the construction, but cannot be manipulated by any Python
code.