[slicer-users] Displaying stdout in a packaged Slicer on Windows
ali.uneri at jhu.edu
Tue Apr 20 12:26:22 EDT 2010
Using "--launch rxvt" produced the same results, but I think I found
the underlying problem and can finally make an official bug report.
The delay in stdout was due to Python "print" command. By default
print operations are supposed to flush stdout, which is not the case
for a print function in a Slicer Python module (on Windows at least).
calling sys.stdout.flush() after each print operation takes care of
the problem, and everything works perfectly.
A side note: I've tried setting output pipe buffering to "none" in
launch.tcl to no avail. It seems the Python prints are stuck before
reaching the pipe (possibly somewhere in Python-to-TCL transition),
and therefore are not processed in the filevent of the pipe.
As a feature request, I would also recommend having launcher options
to popup a wish console (as opposed to rxvt) and/or redirecting the
output to a log file. The wish console can be turned on by calling
"console show" in launch.tcl and a bunch of its parameters can be set
there to suit user needs (e.g. color and font to begin with).
Hope these help. Thank you again for your support and quick response,
On Tue, Apr 20, 2010 at 08:43, Steve Pieper <pieper at bwh.harvard.edu> wrote:
> Hi Ali -
> I see what you mean - did you try using the launch to create a shell with
> the right paths set?
> ./Slicer3 --launch rxvt &
> Inside the newly launched window, you can run:
> There's some more information on debugging here:
> On Apr/19/10 1:01 AM, Ali Uneri wrote:
>> Hello Steve,
>> Thank you for your response, here are some of my experiences with this
>> * I was previously using Slicer3.exe in the bin directory, which was
>> popping up command prompt and working nicely, until I realized
>> interesting bugs (possibly) due to some paths not being set.
>> * Using rxvt does sort of work, but it fails to correctly receive
>> some stdio, e.g. python parsing errors are not displayed, print
>> statements arrive on exit, etc.
>> * Adding "console show" line in launch.tcl has the same effect as
>> rxvt, and suffers from the same issues, but at least does not require
>> * I also tried using "exec" and redirecting the output to a log file;
>> same results as above.
>> I'm not sure of the exact drawbacks (or the actual purpose) in using
>> bin/Slicer3.exe as opposed to the default Slicer3 launcher. It would
>> be nice to be able to use bin/Slicer.exe and bypass TCL, at least for
>> development purposes. Using "Slicer Messages" are very useful, but
>> catching the unhandled errors would be a time saver, especially when
>> scripting CLI modules on the fly.
>> Thank you,
>> On Fri, Apr 16, 2010 at 10:28, Steve Pieper<pieper at bwh.harvard.edu>
>>> Hi Ali -
>>> Stdio on windows is tricky, and I don't think there's a general solution
>>> what you need. The interaction between a windows command prompt vs. the
>>> unix concepts of stdin and stdout isn't always well defined in my
>>> On thing I would strong suggest is using rxvt on cygwin rather than the
>>> prompt or the standard windows console. You can get rxvt (basically a
>>> of xterm) through the cygwin setup.exe interface.
>>> For code in slicer I would suggest using one of the methods below - the
>>> print to stdout, but also add to the slicer log window from which you can
>>> save them out to a file. They also call a native window print function
>>> will try to get the message into the console.
>>> vtkSlicerApplication::InformationMessage(const char* message)
>>> vtkSlicerApplication::WarningMessage(const char* message)
>>> vtkSlicerApplication::ErrorMessage(const char* message)
>>> vtkSlicerApplication::DebugMessage(const char* message)
>>> On Apr/7/10 8:18 PM, Ali Uneri wrote:
>>>> It seems that launch.tcl is suppressing stdout on Windows.
>>>> Running bin/Slicer3.exe through launcher (as opposed to
>>>> bin/Slicer3-real.exe) seems to pop up a Slicer3-real command prompt
>>>> screen, but nothing is displayed, and there is no clear way to
>>>> redirect the actual stdout to this console window. FYI, our package
>>>> has been built against a version of Slicer with win32-console enabled.
>>>> On the same line of thought, would it be possible to also redirect
>>>> stdout to a log file?
>>>> Thank you,
>>>> slicer-users mailing list
>>>> slicer-users at bwh.harvard.edu
>>>> To unsubscribe: send email to
>>>> slicer-users-request at massmail.spl.harvard.edu with unsubscribe as the
More information about the slicer-users