From: Bruce S. <bas...@nc...> - 2010-10-10 04:11:19
|
In the "For developers" section of vpython.org is a zip file containing experimental code for doing either the convenient "from visual import *" or a clean "import vpython". Please try this out and post comments about whether this would meet your needs, or how it should be changed, or offer a different scheme entirely. Once we reach agreement, this will become a part of VPython 5.4 for Python 2.7 and Python 3.1. I was able to follow the suggestion to put almost everything in the new vpython folder, so that the visual folder mostly just imports from the vpython folder. I thought it might be possible, and clean, to put the two modules inside one folder, but that doesn't work. I'm very hazy on how the import search works. If you see a way to have one folder rather than two, please explain. As far as I can tell from my tests, there is complete backward compatibility with existing programs. Bruce Sherwood ----------------------------------------------------------------------------- Here are the installation instructions in the accompanying README file: 1) Before making any changes to your current site-packages, make a copy of site-packages/visual 2) Replace site-packages/visual with the visual folder in this package. 3) Add to site-packages the vpython folder in this package. 4) From your saved copy of site-packages/visual, copy into the new vpython folder cvisual.pyd (Windows) or cvisual.so (Mac) 5) On Windows, from your saved copy of site-packages/visual, copy the doc and examples folders into the new visual folder. After making these changes, you can still use "from visual import *" if that is convenient, but if you want to import the visual objects cleanly, import them from the new vpython module. Here are two simple examples: import vpython as vp vp.box(color=vp.color.orange, material=vp.materials.wood) from vpython import (box, color, materials) box(color=color.orange, material=materials.wood) There are new clean modules vpython.controls, vpython.filedialog, and vpython.graph that can be used instead of the old modules visual.controls, visual.filedialog, and visual.graph. The old modules execute "from visual import *" and are retained because some programs expect that behavior when importing one of these modules. |