TCanvas GUI


is there another way to keep the TCanvas GUI alive, allowing other processes to carry on, other than an infinite while loop as in the tutorials?

## wait for input to keep the GUI (which lives on a ROOT event dispatcher) alive if __name__ == '__main__': rep = '' while not rep in [ 'q', 'Q' ]: rep = raw_input( 'enter "q" to quit: ' ) if 1 < len(rep): rep = rep[0]

I am working on embedding a TCanvas window into pygtk, and it all works great - except the TCanvas simply flashes up and disappears each time.

any help you can give me would be great

thank you


the loop is just to keep the interpreter active, not to keep the TCanvas per se alive (although it does get destroyed when the interpreter exits). At some point you will always need a mainloop to dispatch GUI events, and likely pygtk will provide one for you.

I haven’t seen your code, but if you see the TCanvas only flash-by, then it sounds like all references (from python) have been lost to it. To keep it alive, you’ll need at least one outstanding reference.

For example, this:def createCanvas(): c = TCanvas()
will cause a flash-by when called, since ‘c’ will be collected at the end of the function. It needs to be held by e.g. a frame and set to self.mycanvas = TCanvas() or something similar.