> So far so good. But, where one needs to pay attention is when running
> a Python script within LEO (typing CTRL-B on a node executes the
> script contained in the body of that node). The Python that runs the
> script is the same as the Python running LEO. It is not another
> instance.

I have a project which needs to use python 2.5, which Leo doesn't run
on anymore. The method I use to keep using Leo with this project is to
create a button which opens a shell with the correct python
environment. It's not as quick or smooth as [Ctrl]-[B] to use Leo's
active interpreter, but it helps.

1. create a node "@button pyshell here" in the foobar-project.leo.
Body contents for that node:

-----
@
Open a windows cmd.exe prompt in the path of the currently selected node.
A mapped drive letter will be created for a UNC path.

Adapted from:
    
http://webpages.charter.net/edreamleo/scripting.html#working-with-directives-and-paths
    http://www.mail-archive.com/[email protected]/msg12177.html
@c

d = c.scanAllDirectives(p)
# g.es(g.dictToString(d))   #uncomment to show results of above in log pane

#path = d.get('path')
path = c.getNodePath(p)

name = p.anyAtFileNodeName()
if name:
   name = g.os_path_finalize_join(path,name)
   g.es(name)

from subprocess import Popen
#Popen(r'cmd.exe /k pushd %s' % path)
Popen(r'%s/pyshell.bat' % path)
-----

2. Create pyshell.bat in my foobar-project directory:

-----
@echo off
echo.
echo.   Setting environment for python
echo.
set PYTHONHOME=C:\Python25
set 
PYTHONPATH=%PYTHONHOME%;%PYTHONHOME%\Lib;%PYTHONHOME%\DLLs;C:\ESRI\ArcGIS\Bin
set PATH=%PYTHONHOME%;%path%
set py
python --version
echo.

:: add directory of the pyshell script to PATH
pushd %~dp0
set path=%path%;%~dp0

cmd /k
-----

-- 
-matt

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to