I’m a long-time user of python and ROOT, first time user of PyROOT, and I’m having trouble getting my program to end. Here’s the code, with comments about my understanding of what it does:
import sys
import random
import ROOT
ROOT.gApplication.SetReturnFromRun(0)
##When the ROOT thread terminates, take the python process with it
print ROOT.gApplication.ReturnFromRun()
##Check to make sure the bool is set, result is “0”
hist = ROOT.TH1F(“hist”,“test”,100, 0, 1)
for x in range (1, 1000):
hist.Fill(random.random());
hist.Draw();
##Fill hist & draw
ROOT.gApplication.Run()
##Start the ROOT api thread: roughly equivalent to Tkinter’s .mainloop()
ROOT.gApplication.Terminate(0)
##When the ROOT api thread has finished (e.g. the user
##has selected “Quit ROOT” in the gui), gApplication is deleted
sys.exit(0)
##Force the python process to terminate
What happens is that I get an “automatically generated” canvas with the plot, which I can manipulate as I like. However, the process never terminates. If I try to do “Quit ROOT”, I’m stuck–updating of the canvas gets turned off, but the process doesn’t terminate. Either way, I can’t even out of the process; I have to “kill -9” it from another xterm.
Am I missing a concept here? Or maybe just some keystrokes?
Thanks for the help,
Julie