RE: Continue after TApplication::Run()

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Wed, 04 May 2005 18:38:15 -0500


Hi,

The example is now working as expected in ROOT 4.04/00 and above

Cheers,
Philippe

-----Original Message-----
From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch] On Behalf Of Thilo Pauly
Sent: Wednesday, May 04, 2005 3:22 AM
To: roottalk_at_pcroot.cern.ch
Subject: [ROOT] Continue after TApplication::Run()

Dear ROOT team,

I'm trying to include the ROOT graphics capabilities into an existing piece of code that interacts with the user through a simple command line interface. Basically the user makes the program do some computations, and I'd like the program to display a histogram, and then prompt again for the next command. In the meantime it would be nice to have all Gui capabilities for the existing canvas, so that the user could zoom into the histogram, change the labels, and make a print-out, etc.

I googled a bit and found a "apparently official" code example, which more or less would be what I need. Unfortunately it gives me an error (I'm using root version 4.03/02 on lxplus SLC3), which I assume is related to the fact that the canvas does not exist anymore after I select the "quit root" menu point.

In addition, is there a way to have the canvas being displayed with all its interactive menu, but continue with the program after theApp.Run()?

Many thanks for you help!
Thilo


Error in <RootX11ErrorHandler>: BadDrawable (invalid Pixmap or Window parameter) (XID: 8388887, XREQ: 62)


#include "TROOT.h"
#include "TApplication.h"
#include "TCanvas.h"
#include "TLine.h"
#include "TPaveLabel.h"

extern void InitGui();
VoidFuncPtr_t initfuncs[] = { InitGui, 0 }; int Error; // needed by Motif

TROOT root("hello","Hello World", initfuncs);

int main(int argc, char **argv)
{

   TApplication theApp("App", &argc, argv);

   TCanvas *c = new TCanvas("Hello", "The Hello Canvas", 400, 400);    c->Show();

   TPaveLabel *hello = new TPaveLabel(0.2,0.4,0.8,0.6,"Hello World");    hello->Draw();
   c->Update();

   // Enter event loop, one can now interact with the objects in
   // the canvas. Select "Exit ROOT" from Canvas "File" menu to exit
   // the event loop and execute the next statements.
   theApp.Run(kTRUE);

   TLine *l = new TLine(0.1,0.2,0.5,0.9);    l->Draw();
   c->Update();

   // Here we don't return from the eventloop. "Exit ROOT" will quit the app.

   theApp.Run();

   return 0;
} Received on Thu May 05 2005 - 01:48:27 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:07 MET