Render the canvas while a script is still executing

Hi, I am writing a script that takes some data and then draws it to the canvas. I have been experimenting with some loops and found that the canvas is not actually drawn until the script terminates. For example, if i add an infinite loop after the ->Draw() command, the canvas stays white and does not refresh. If i terminate my script after the ->Draw() command, the canvas shows the correct plots. Is there any way to force the canvas to update from within a script?

Thanks

After you draw something execute:
gPad->Modified(); gPad->Update();

BTW. inside of your “infinite loop” add:
gSystem->ProcessEvents();

Sorry to bring this post back up. I have used the code that you suggest and indeed the canvas does draw and events are visible. However, I cannot interact with the canvas, such as re-scaling histograms. Is this possible within a loop?

Are you doing anything “useful” in your “infinite loop” or is it just there to keep your canvas “alive”?

In the latter case, I would say you should try to use this …
In your “main”, right in the beginning:
TApplication *a = new TApplication(“a”, 0, 0);
and then, whenever you need a “dummy infinite loop”:
a->Run(kTRUE); // return here using “any canvas main menu” -> “File” -> "Quit ROOT"
This way you will always get a “fully featured” ROOT running for you.

What concerns any possible “gSystem->ProcessEvents();” limitations, I’m afraid the one who’s responsible for it needs to answer this question.

I am just using the infinite loop to read in user input. For a data file with a number of events in, the user can enter a number then the canvas redraws to show information from that particular event. The script I have performs analysis on all events, but only displays information for a particular event, so rerunning the whole script to display a new event would not be practical.

I would be helpful if you could send a small script reproducing your problem.

Hi,

AFAIK, there is no limitation in gSystem->ProcessEvents()…

Cheers Bertrand.