Waiting for user input in the gui app

Hello,

I have a gui PyROOT app that uses this loop after main:

	rep = ''
	while not rep in [ 'q', 'Q' ]:
		ROOT.gSystem.ProcessEvents()
		rep = raw_input('enter "q" to quit: ')
		if 1 < len(rep):
			rep = rep[0]

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?

Hi,

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.

Cheers,
Wim

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.