While loop hangs (and it drives me nuts!) :(
Guys...i can't get my head around this so hopefully one of you could help. Here's the situation I'm facing. I prepared an experiment where I show on a canvas the names of two towns and ask participants to enter their estimate of the distance between them and press enter. I have a list with 171 pairs of towns and I randomly select a pair for each trial. Everything works well except that the experiment hangs at what seem to be a random point (i.e., different pair of towns each time, different point through the experiment). That is, I go through the experiment and at some point when a pair is presented, I enter my response, but nothing happens when I press enter. No error is printed and I have to close OS with control-alt-delete. I suspect it's something to do with the while loop I use to present the trials. I paste the code below for that loop...can anyone spot anything wrong with it? thanks in advance!
while True: my_canvas.text(text=var.town1,x=x_center-200, y=y_center, color=u'white') my_canvas.text(text=var.town2,x=x_center+200, y=y_center, color=u'white') my_canvas.show() key, time = my_keyboard.get_key() if key=='return': my_canvas.clear() self.experiment.set("response", resp) var.response_time = time - start_time var.error_km = int(resp) - var.corr_distance_km break if key=='backspace': my_canvas.clear() resp = resp[:-1] my_canvas.text(resp, y=y_center+150) else: resp += key my_canvas.clear() my_canvas.text(resp, y =y_center+150)