I have some code that generates a TCanvas, draws a histogram, and then Print()'s the canvas to a .png file.
The TCanvas pops up on the screen which makes the application look unprofessional. I would like to create a .png without the TCanvas popping up on the screen. Can this be done?
You can set batch mode only while you create canvas and store png file:
gROOT->SetBatch(kTRUE);
auto c1 = new TCanvas("c1","c1", 500, 500);
// draw all your objects here
c1->Print("c1.png");
delete c1;
gROOT->SetBatch(kFALSE);