Re: [ROOT] Redirection of “cout”

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Tue Nov 06 2001 - 20:31:34 MET


You will have to redirect stdout using code like in TProofServ::RedirectOutput()
to a tmp file. Then you would have to register a TFileHandler with a read
mask so that the event loop will check this file if there is something to read.
Then in this TFileHandler::ReadNotify() you read the text and display it in
a TGTextView widget. You can use a TGTextEdit or TGTextEntry widget for
CINT command line input and process it via gROOT->ProcessLine().

The only problem is that the output will be synchronous, i.e. if you create
a lot of output on stdout while in a processing routine the output will only be 
displayed when returning to the eventloop. To update the output during
processing
you will have to call regularly gSystem->ProcessEvents(). If you control the
processing loop this might not be a problem.

Another solution is to make a stand alone terminal emulator program and let
that fork and start your main app, now this terminal emulator can send
and receive stdin/stdout via a pipe with the main app and this works fully
asynchronous since there are now two independent processes running.

Cheers, Fons.




"cstrato@EUnet.at" wrote:
> 
> Dear Rooters
> 
> For my GUI application I would like to re-direct the output of ?cout?
> to a TGFrame such as TGTextEdit. Is this possible, and how?
> Is it also possible to use TGTextEdit as  input for ?cint??
> 
> Thank you in advance
> 
> Best regards
> Christian
> ----------------------------------
> C.h.r.i.s.t.i.a.n  S.t.r.a.t.o.w.a
> V.i.e.n.n.a,  A.u.s.t.r.i.a

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7679480



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:06 MET