[Tutor] I'm tring to translate a Tcl/Tk program into Python.

SA sarmstrong13@mac.com
Thu, 13 Jun 2002 12:35:01 -0500


Hi Everyone-

    I am trying to translate a tcl program that use tk into python. I seem
to be going along fine until I get to the process that wants to "catch" the
results onto one text screen. Here is what I am looking at:

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

Basically, this process catches the output from running the code in the text
widget .t1 through python -c and places it into the variable ouput.
The text widget .t2 is then cleared and the contents of the variable $output
are displayed in the text widget .t2.

I can translate all of the widgets into python/tkinter code, but I'm not
sure about how to translate this process. Is there a function similar to
"catch" in Python?

Thanks.
SA