def run(self):
"""Process command queue and enter turtle main loop"""
if self.closed:
raise PlotClosed('Plot window closed')
opened = False
try:
while True:
try:
cmd = self.queue.get(timeout=1)
break
except queue.Empty:
pass
if cmd != self.do_close:
opened = True
self.do_zoom()
self.do_clear()
cmd()
turtle.ontimer(self.check_queue, 100)
turtle.mainloop()
except turtle.Terminator:
pass
except KeyboardInterrupt:
pass
finally:
self.closed = True
if opened:
try:
turtle.bye()
except turtle.Terminator:
pass