[Edu-sig] Re: Teaching graphics with Python (was Introductoryhighschool programming)

Arthur ajsiegel at optonline.net
Sat Jul 31 22:00:43 CEST 2004


> I wanted to thank you for this stereoscopic feature in VPython, and 
> suggestion that I use it.

Just thought I'd mention that VPython 3.0 has been released last week.  This
version is mostly a behind the scenes revamp of the code.  VPython now uses
the Boost Python library to expose Vpython's cvisual C++ code to Python. 

Among other things this allows one to directly subclass cvisual primitives
in pure Python. Currently this is an undocumented facility as to VPython.

But getting it down to its essentials, the following runs, and provides a
sphere primitive that insists on being blue.

import cvisual
import time
import atexit

def __waitclose():
    while not cvisual.allclosed(): time.sleep(0.05)
atexit.register(__waitclose)

scene = cvisual.display()

class sphere (cvisual.sphere):
    def __init__( self,*args,**keywords):
        cvisual.sphere.__init__(self)
        self.color=(0,0,1)
        self.complete_init( self, self,
             1, scene, None)

s=sphere()

Seems to me this facility will open up interesting new possibilities in
having fun with VPython/cvisual.

PyGeo for example could now decide to more truly wrap the cvisual library,
as opposed to using it - through Vpython - as a rendering back-end.
> 
> My slides are here:
> http://www.4dsolutions.net/oscon2004/ (might be some minor problems if 
> viewed in Windows, not sure (tried to make it work well in both, but 
> kept finding little discrepancies going back and forth, and did all 
> last minute editing on the Linux side)).

Looks super.

Art



More information about the Edu-sig mailing list