Upstream version 1.3.40
[profile/ivi/swig.git] / Examples / python / class / runme.py
1 # file: runme.py
2
3 # This file illustrates the proxy class C++ interface generated
4 # by SWIG.
5
6 import example 
7
8 # ----- Object creation -----
9
10 print "Creating some objects:"
11 c = example.Circle(10)
12 print "    Created circle", c
13 s = example.Square(10)
14 print "    Created square", s
15
16 # ----- Access a static member -----
17
18 print "\nA total of", example.cvar.Shape_nshapes,"shapes were created"
19
20 # ----- Member data access -----
21
22 # Set the location of the object
23
24 c.x = 20
25 c.y = 30
26
27 s.x = -10
28 s.y = 5
29
30 print "\nHere is their current position:"
31 print "    Circle = (%f, %f)" % (c.x,c.y)
32 print "    Square = (%f, %f)" % (s.x,s.y)
33
34 # ----- Call some methods -----
35
36 print "\nHere are some properties of the shapes:"
37 for o in [c,s]:
38       print "   ", o
39       print "        area      = ", o.area()
40       print "        perimeter = ", o.perimeter()
41
42 print "\nGuess I'll clean up now"
43
44 # Note: this invokes the virtual destructor
45 del c
46 del s
47
48 s = 3
49 print example.cvar.Shape_nshapes,"shapes remain"
50 print "Goodbye"
51