This chapter tells how to install and run Leo.
Important:
If you have any problems installing Leo, please ask for help on Leo's help forum:
Contents
Leo will work on any platform that supports Python 2.2.1 or later and Tk 8.4 or later.
Download the latest version of Leo from Leo's download page.
Download Python from: http://python.org/
Most installations of Python have Tk pre-installed. If your doesn't, you may download it from: http://tcl.activestate.com/software/tcltk/
Warning: When building Tcl on Linux, do not specify "--enable-threads". Only use Tcl with the default "threads not enabled" case.
Leo uses Pmw (Python Mega Widgets). Leo's extensions folder contains a copy of Pmw for use if needed. Leo first tries to import Pmw normally. If that fails, Leo will use the version of Pmw in the extensions folder.
Download the latest version of Leo (a .zip file) from Leo's download page.
Unzip the downloaded .zip file into a folder in your home directory. The folder will be called something like leo-4-4-3-final.
You now have two choices:
You can run Leo from your home directory. Just add ~/leo-4-4-3-final to your path.
You can install leo into /usr/local/lib and /usr/local/bin by running Leo's install script as follows:
cd ~/leo-4-4-3-final chmod u+x install sudo ./install
The install script will instruct you to add /usr/local/bin to your path.
Now you are ready to run Leo.
Leo is distributed either as an executable installer (.exe) file or as a .zip file.
To install Leo using the executable installer:
- Download the latest version of Leo's installer from Leo's download page. The installer will be called something like LeoSetup-4-4-3.exe.
- Run the installer. By default, the install will install Leo in your 'Program Files' directory.
To install Leo from the .zip file:
- Download the latest version of Leo (a .zip file) from Leo's download page.
- Unzip the .zip file and place the unpacked leo folder in the 'Program Files' folder or any convenient location.
After you have installed Leo, you should add the location of your leo/src folder to your python path. One way to do this is adding something like the following to python/Lib/sitecustomize.py:
import sys sys.path.append(r'<path-to-leo>leo\src')
Another way is to append <path-to-leo> to the Windows PYTHONPATH environment variable.
Now that you have installed Leo and told Python where to find Leo, you are ready to run Leo.
Note: If you haven't already created a HOME environment variable, it would be good to define home to be "%USERPROFILE%My Documents". You can check whether HOME exists by typing 'echo %HOME%' (without the quotes) in a console window.
Leo will open .leo files automatically provided that you associate leo.py with .leo files. Here is how to open Leo when double-clicking a .leo file on Windows 2K or XP:
You now have to tell windows what to do to open the file properly:
Press the new button to open the New Action window.
In the Action field type Open, then type one of the following lines:
[python install dir]\pythonw.exe [leo install dir]\leo.py %1 [python install dir]\python.exe -i [leo install dir]\leo.py %1
Important: The -i option is not valid when using pythonw.exe. Any call to pythonw -i will cause pythonw.exe to exit immediately.
The first line opens Leo files with no console window. The second line opens Leo files with a console window and leaves the window open after Leo exits. You should now be able to double click on a leo file in explorer with Leo.
By Randall Voth: Leo works reliably only on MacOS X 10.3 (Panther) and above. To run Leo on Macintosh OS X 10:
This documents how I used Platypus 3.0 to create MacLeo, the MacOS X launcher for Leo. You don't need Platypus to _use_ MacLeo, but you do need Platypus to create MacLeo. You may download Platypus 3.0 from http://sveinbjorn.vefsyn.is/platypus Platypus creates something called an "application bundle," essentially a wrapper for the shell script called openLeoScript.sh.
At present this script contains just:
#!/bin/sh # $2 only works if .leo is one of the extensions. /usr/bin/pythonw ~/leo/src/leo.py $2
In detail, here is how I created MacLeo:
Open Platypus.
Set the Platypus settings:
- Name: MacLeo - Script type: shell - Icon: Python Icon - Using the standard Leo outline doesn't work, but one could be created… - Script Path: /Users/edream/dist/Platypus 3.0/openLeoScript.sh - Is droppable checkbox (checked) - Edit Types: .leo only, not *, not folders. - N.B. There MUST be a period in front of .leo! Otherwise $2 will be empty in the script. - Output: None (progress bar and text window appear to be essentially useless)
Hit the create button to create MacLeo.
This tells how I created leo-4-3-a3.pkg using PackageMaker.
PackageMaker is included in the Xtools disk that comes with MacOS X. Installing PackageMaker was easy, but I don't remember the details.
You can run Leo from a Python interpreter as follows:
import leo leo.run() # runs Leo, opening a new outline. leo.go() # runs Leo after reloading all modules. leo.leoOpen(fileName) # runs Leo, reloads all modules, and opens fileName.
Here are some tips that may make running Leo easier:
The following shell script will allow you to open foo.leo files by typing leo foo:
#!/bin/sh python <leopath>/leo.py $1
where <leopath> is replaced with the path to the leo directory.
If you have associated .leo files with Leo you may run Leo by double-clicking any .leo file. You can also use a batch file. Put the following .bat file in c:\Windows:
cd c:\prog\LeoCVS\leo c:\python22\python c:\prog\LeoCVS\leo\leo.py %1
This opens the file specified by the first argument (%1).
The first time you start Leo, a dialog will ask you for a unique identifier. If you are using cvs, use your cvs login name. Otherwise your initials will do. Leo stores this identifier in the file .leoID.txt. Leo attempts to create leoID.txt in your home directory, then in Leo's config directory, and finally in Leo's src directory. You can change this identifier at any time by editing .leoID.txt.
On startup, Leo looks for two arguments of the form:
--script scriptFile
If found, Leo enters batch mode. In batch mode Leo does not show any windows. Leo assumes the scriptFile contains a Python script and executes the contents of that file using Leo's Execute Script command. By default, Leo sends all output to the console window. Scripts in the scriptFile may disable or enable this output by calling app.log.disable or app.log.enable
Scripts in the scriptFile may execute any of Leo's commands except the Edit Body and Edit Headline commands. Those commands require interaction with the user. For example, the following batch script reads a Leo file and prints all the headlines in that file:
path = r"c:\prog\leoCVS\leo\test\test.leo" g.app.log.disable() # disable reading messages while opening the file flag,newFrame = g.openWithFileName(path,None) g.app.log.enable() # re-enable the log. for p in newFrame.c.allNodes_iter(): g.es(g.toEncodedString(p.headString(),"utf-8"))
You must install the Aspell package if you want to use Leo's Spell tab.