2
votes

I'm running Windows 8. I have a file named "test.tcl".

  • If I open a shell, type "wish", then 2 windows open. In one of them, I can type Tcl code and open the file test.tcl. If I open this file, its code is executed.
  • If I double click on test.tcl to open the file with "Wish Application", then 1 blank window open, and nothing happens.

Do you know why please?

1
Are you sure that nothing happens? The code in test.tcl should execute and the window appears when the execution is complete in the second case. - Jerry
The code that I have tested is "puts a". I don't see "a". - Arnaud
That's because the window you see is not stdout (the default output channel for puts). Try putting something to create a text file like set f [open "output.txt" w]; close $f and you'll see a file appear, meaning the code executed. You could open the file at the start, then put everything into that file by using puts $f a before closing it. You'll see the output in that file. - Jerry

1 Answers

2
votes

On Windows, Wish is built as a GUI-only application; it has no real standard output available. Tk fakes one for you though; just put this in your script to show the fake console:

console show

The fake console shows up by default when you launch without a script file, but launching with a script file doesn't show it (so your script file can implement an application, of course).

This can catch people out when they produce a lot of output on stdout. Tk may well be keeping it all faithfully just in case the code does console show later on, though it looks and smells a lot like a memory leak if you're not prepared for it…