RE: Continue after TApplication::Run()

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


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


-----Original Message-----
From: [] On Behalf Of Thilo Pauly
Sent: Wednesday, May 04, 2005 3:22 AM
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!

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();

   // 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.

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

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


   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