PageRenderTime 29ms CodeModel.GetById 22ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/Root-branch-php-utl/SWIG/Examples/python/shadow/runme.py

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