SetBatch() and come back

Hi,

for some reason, I have a program in where I want to turn into batch mode to avoid having histograms popping up, but in some other part of the program I want to generate some canvases with the TBrowser class.

I tried the following with no success:

 TApplication theApp = new TApplication("App", &argc, argv);
theApp->Run(); 
....
   gROOT->SetBatch();
.... part of the program with no graphics. 
  gROOT->SetApplication(theApp);
.... part of the program with graphics.

I also tried with theApp->Hide() which didn’t work and theApp->Terminate() which kills my program (I didn’t understand how to use the SetReturnFromRun()).

How do I turn into batch mode (or any kind of quiet mode) and then come back to the application mode?

Thanks, Ciao.

fede.

Hi,

Please try like this: TApplication theApp = new TApplication("App", &argc, argv); // initialize graphics (load graphics and gui libraries) TApplication::NeedGraphicsLibs(); gApplication->InitializeGraphics(); .... gROOT->SetBatch(kTRUE); .... part of the program with no graphics. gROOT->SetBatch(kFALSE); .... part of the program with graphics. theApp->Run();
Bertrand.

It didn’t work. Maybe I didn’t expain myself correctly… I’m running a GUI application with the ROOT libraries so that’s why my main() now looks like this:

int main(int argc, char **argv)
{
   theApp = new TApplication("App", &argc, argv);
   if (gROOT->IsBatch()) {
      fprintf(stderr, "%s: cannot run in batch mode\n", argv[0]);
      return 1;
   }
   TApplication::NeedGraphicsLibs();
   gApplication->InitializeGraphics();
   TestMainFrame mainWindow(gClient->GetRoot(), 400, 220);
   theApp->Run();
   return 0;
}

Then, when I hit a button to lunch a macro I do:

gROOT->SetBatch(kTRUE);
DoWork();
gROOT->SetBatch(kFALSE);

That’s why I placed the theApp->Run() right at the beginning and I can’t place it after generating the canvases. But with this GUI application I run macros to build some histograms from which I don’t want to see the canvases popping up and I want to go to batch mode when I run these macros, but I want to get back to graphics mode when I open a TBrowser to open some Trees and canvases saved into a .root file. Is this possible or I just need to delete canvases as soon as I draw and write them into a .root file? or just tell me how can I avoid Canvases from popping up?!?

thanks.

fede.