From: Justin Gullingsrud (justinrocks_at_gmail.com)
Date: Fri Oct 29 2004 - 00:23:29 CDT

Hi Lars,

On Thu, 28 Oct 2004 12:04:06 +0200, Lars Bruno Hansen
<lhansen_at_fysik.dtu.dk> wrote:

> >
> Hi Justin,
>
> We are in a small way using the python prompt in a tool which can display
> our trajectory format. From the python command you have methods for showing
> the force vectors and writing back the atoms to a new trajectory file,
> methods which are specific to the tool.
> But more important, you have also access to the atoms and can
> use any methods on these, eg. you can set new positions for
> them and vmd's graphics window will follow, or the other way around
> you can move the atoms using the mouse and see the change
> in the python atoms, or if you have a tool for rotating a subset of
> the atoms you can use that etc etc.
> This flexibility, it may not be use very much, but it is there if needed,
> and is a big advantage to a graphical user interface, with a fixed
> set of posibilities.

Right; I wasn't suggesting doing away with the Python interface all
together, just wondering whether anyone ever types "gopython" from the
vmd> prompt and starts entering Python code from within VMD. An
alternative would be write your Python code somewhere else, save it in
a file, then run it using the other form of the gopython command,
"gopython somefile.py". I actually love Python's requirement of
indenting, but the indenting makes it difficult to type more than very
trivial scripts from the VMD console. Embedding Idle within VMD, much
like we embed TkCon for Tcl scripting, might be all our users need for
interactive Python scripting.

>
> I was thinking about the vmd/python build problem.
> Would it be an idea to build the python interface on top of vmd's tcl
> scripts
> interface.
> The tcl interface I understand from the discussion is easier to maintain
> within
> vmd. A ordinary vmd-python module could be installed by the user ,
> using the regular python iterpreter. This vmd-python module would contain
> the current code, modified on the lowest level.
> VMD would have to start the external python and load the vmd-python module.
> The communication between vmd's tcl interface and python could be via a
> pipe.
> The vmd-python module could have the same version number as vmd, being
> only
> dependent on vmd's tcl script interface. In main vmd one would now only
> have to
> maintain one script interface. The python callback method could be a
> problem.

There are still a number of issues to be worked out before VMD could
be made act like a well-behaved Python module. I'm not quite sure
what you had in mind for how VMD would be controlled from Python:
would you simply have Python pass Tcl commands as strings to vmd and
get the result back? One could do this, but it wouldn't really be any
more useful that just starting VMD as a sepate process and
communicating with it over sockets; i.e. there's really no VMD Python
interface at all in that world. Don't get me wrong, this approach is
sufficient for things like controlling VMD from a web page, but you
then have to learn the Tcl interface anyway.

Thanks for all the feedback, by the way.

Cheers,
Justin

>
> with best regards
> Lars
> --
> Lars Bruno Hansen
> CAMP, Dept. of Physics, Building 307, DTU, DK-2800 Lyngby, Denmark
> Phone: +45 45 25 32 16 Fax: +45 45 93 23 99
> E-mail: lhansen_at_fysik.dtu.dk
>
>

-- 
The spirit of Plato dies hard.  We have been unable to escape the
philosophical tradition that what we can see and measure in the world
is merely the superficial and imperfect representation of an
underlying reality.
                -- S.J. Gould, "The Mismeasure of Man"