I have a gui PyROOT app that uses this loop after main:
rep = ''
while not rep in [ 'q', 'Q' ]:
rep = raw_input('enter "q" to quit: ')
if 1 < len(rep):
rep = rep
the problem is, that in the code I would like to draw a canvas, and on user pressing some key redraw a canvas with a different graph and do this a few times. So I would add raw_input() to the loop in which I draw into canvas, but then it conflicts with the main raw_input() of the application. How such situations should be handled?
not quite following … is the key press for redrawing being handled by the GUI or the CLI? If the GUI, and the raw_input only needs to exist to keep the python interpreter from closing, you can also run ‘ROOT.gApplication.Run()’ instead. If the CLI, well, there is only one, so you’d have to take all input and write your own dispatcher.
Thanks! I am running the GUI, however relying on CLI sometimes (much faster to accept “n” input on console than add a “next” button to a standard canvas). I did not know about ROOT.gApplication.Run(). Now I switched to it getting keyboard input on CLI only where really necessary.