Windows in batch mode

Dear all,
this little snippet of code works when executed like

root run.C

run.C:
{
cout << “blabla” << endl;
TCanvas* c123 = new TCanvas(“c123”,“c123”,1600,800);
c123->cd();

TGraph* gr = new TGraph(2);
gr->SetPoint(0,1,1);
gr->SetPoint(1,2,2);

gr->Draw(“apl”);
gPad->Update();
}

Them, I was trying to run it in batch mode via a python script:

script.py:

import os

print "start script"
bashCommand = "root.exe -b run.C"
os.system(bashCommand)

but now, the Canvas is not dislplayed.

I searched hence through the forum and found tipps like adding
gROOT->SetBatch(kTRUE);
gSystem->SetDisplay();
and these sort of things, but it doesnt work.

What am I doing wrong?

Thanks!

Hi,

By definition, running in batch mode means no window, so if you want to see your canvas, don’t run in batch mode… For example:
bashCommand = “root.exe -l run.C”

Cheers, Bertrand.

thanks, it works, and of course I should do gROOT->SetBatch(kTRUE); :wink:

Hi,

[quote=“jansen”]thanks, it works, and of course I should do gROOT->SetBatch(kTRUE); [/quote]Nope, you should do gROOT->SetBatch([color=#FF0000]kFALSE[/color]);!

Cheers, Bertrand.