A simple tcl/tk program to run Python.

SA sarmstrong13 at mac.com
Tue Jun 4 20:49:42 EDT 2002


Hi Everyone-

    I found this script at :
http://mini.net/tcl/1805.html

It was written by Hugh Dunne as kind of an Idle for Perl on a windows
machine. I modified it to run Python scripts instead. The difference between
this and Idle is that it does not immediately execute your code. And keeps
the code visible so you can go back and edit the mistakes. I think it's cool
because after about twenty lines of code in Idle I tend to forget whether or
not I "import"ed the correct module and then I start losing my spot. So it
is kind of good as a simple code debugger. I want to try and code the same
thing in Python because I find it more useful than Idle. (anyone willing to
help, please jump in).

Let me know what you think, if there are any adjustments you would like to
make, and if it works properly for you. So far I've run it with simple
functions and calling them in the program seems to work OK.

Thanks.
SA

Here's the code:

#!/usr/bin/wish

text .t1 -height 12 -width 84 -font {Courier 12}
frame .f
text .t2 -height 8 -width 84 -bg lightblue -font {Courier 9}
button .f.b1 -text Execute -command perl
button .f.b2 -text "Clear input" -command ".t1 delete 0.0 end"
button .f.b3 -text "Clear output" -command ".t2 delete 0.0 end"
pack .f.b1 .f.b2 .f.b3 -side left -padx 2
pack .t1 .f .t2 -side top -pady 2

proc perl {} {
        catch {exec python -c [.t1 get 0.0 end]} output
    .t2 delete 0.0 end
    .t2 insert end $output
}




More information about the Python-list mailing list