What: Leo

 Where: http://leoeditor.com/
 Description: Leo is a programmer's editor and a flexible browser for projects,
       programs, classes or data. Leo clarifies design, coding, debugging, 
       testing and maintenance. Leo is an outlining editor. Outlines clarify 
       the big picture while providing unlimited space for details. Leo is a 
       literate programming tool, compatible with noweb and CWEB. Leo enhances 
       any text-based programming language, from assembly language and C to Java, 
       Python and XML. There is a Tcl/tk mode so Leo is aware of Tcl commands. 
       What I particularly like is the ability to have all my code and 
       documentation together in one place and publish the code when I save the file. 
       When I change the code in another editor, then open it in Leo, the Leo file is 
       updated automatically.
       Runs wherever Python runs. [Has anyone else noticed that Python seems to 
       stimulate programming creativity and a number of innovative systems have been 
       released in this language recently. This is not saying that I am not impressed by 
       some of the Tcl/tk programs I have come across here: I am!]
 Updated: 3/July/2014
 Contact: See web site.

escargo - 2014-07-03: Note that at some point in its evolution, Leo became a PyQT application, no longer using Tkinter.

Brian Theado 24Oct2005 - Since Leo is built using Tkinter, it has fairly easy access to making calls to Tcl and Tk. Leo provides an outline of "headlines" and with each headline body text can be associated. There is a scripting plugin (I think it is enabled by default, I don't remember) that makes it easy to run python scripts. It comes with a button called "Run Script" that will execute the current body text as a Python script. It also allows new toolbar buttons to be created and associated with a given node's body text.

It is easy to create a "Run Tcl" button that will execute body text in the Tcl interpreter.

First create a node with the headline "@button Run Tcl". Then enter the following text in the body of that node:

 tk = g.app.root.tk

Then create the "Run Tcl" button by clicking on the "Script Button" button. Now the "Run Tcl" button will execute the tcl code in the current body text and display the return value in the log pane.

You can try it by creating the following body text and clicking "Run Tcl":

 set x 50
 return [expr $x*10]

500 will be displayed in the log pane.

If you are going to be doing your own Tk stuff, then it might be better to change the "Run Tcl" button so it creates a new toplevel each time (and maybe it is a new interpreter as well--I'm not sure as I don't know tkinter):

 import Tkinter
 tk = Tkinter.Tk().tk

Execute the following python script to create a function named "log" in the Tcl interpreter that will display the given string to leo's log pane:

 # register the g.es function and rename it in Tcl-land to "log"
 root = g.app.root
 logFunc = root.register(g.es)
 root.tk.eval ("catch {rename log {}}")
 root.tk.call ("rename", logFunc, "log")

I am using Leo 4.3.3

Brian Theado 27Oct2005 - Some help from the leo forums has led me to some even more useful leo scripts than the above. The bodyString method only returns the text from a single node's body. The power of leo comes from being able to create chunks of code can be organized into a hierarchy. A leo function named g.getScript can assemble the text from an entire subtree. This allows you to powerfully organize your code as well as execute bits and pieces of it right from within leo.

So the "@button Run Tcl" code from above becomes:

 s = g.getScript(c,p,forcePythonSentinels=False) 

Yet another approach (05Nov2005 - added 'r' prefix to avoid python backslash substitution [L1 ]):

 s = r''' 

Since this is now pure python on the outside, the standard "Run Script" button and "Script button" buttons will work fine.

The @others is a directive that is replaced by Leo with bodies of the entire subtree. If you have a short Tcl script, you can replace @others with the actual script and leave out the sections.

This on-the-fly scripting functionality, makes Leo a very powerful IDE for Tcl/Tk. The ability to clone nodes (think unix hard links) is a very powerful organizing principle. The clones allow for multiple views on your code and they allow you have have multiple ways of writing out your code to externally executable tcl scripts. And at any time you can select subsets of the hierarchy to execute directly from within the editor. I recommend giving it a try.