Python turtle 模块,Terminator() 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用turtle.Terminator()

项目:jvcprojectortools    作者:arvehj    | 项目源码 | 文件源码
def check_queue(self):
        """Timer callback to check command queue"""
        try:
            while True:
                window_size = turtle.window_width(), turtle.window_height()
                if self.window_size != window_size:
                    self.redraw()
                    turtle.ontimer(self.check_queue, 200)
                    break
                cmd = self.queue.get_nowait()
                cmd()
                if cmd == self.do_close:
                    break
        except queue.Empty:
            turtle.ontimer(self.check_queue, 100)
        except turtle.Terminator:
            pass
        except KeyboardInterrupt:
            turtle.bye()
项目:jvcprojectortools    作者:arvehj    | 项目源码 | 文件源码
def __init__(self):
        self.queue = queue.Queue(maxsize=1)
        self.margin = [0, 0, 0, 0]
        self.plot_area = (0, 0, 255, 1023)
        self.min_size = (2, 8)
        self.zoom_area = [*self.plot_area]
        self.scale = 1
        self.font = ('Ariel', 8)
        self.closed = False
        self.window_size = None
        self.tables = []
        try:
            turtle.setup()
        except turtle.Terminator:
            turtle.setup()
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def startDemo(self):
        self.refreshCanvas()
        self.dirty = True
        turtle.TurtleScreen._RUNNING = True
        self.configGUI(DISABLED, DISABLED, NORMAL, DISABLED,
                       "demo running...", "black")
        self.screen.clear()
        self.screen.mode("standard")
        self.state = RUNNING

        try:
            result = self.module.main()
            if result == "EVENTLOOP":
                self.state = EVENTDRIVEN
            else:
                self.state = DONE
        except turtle.Terminator:
            self.state = DONE
            result = "stopped!"
        if self.state == DONE:
            self.configGUI(NORMAL, NORMAL, DISABLED, NORMAL,
                           result)
        elif self.state == EVENTDRIVEN:
            self.exitflag = True
            self.configGUI(DISABLED, DISABLED, NORMAL, DISABLED,
                           "use mouse/keys or STOP", "red")
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def startDemo(self):
        self.refreshCanvas()
        self.dirty = True
        turtle.TurtleScreen._RUNNING = True
        self.configGUI(DISABLED, DISABLED, NORMAL, DISABLED,
                       "demo running...", "black")
        self.screen.clear()
        self.screen.mode("standard")
        self.state = RUNNING

        try:
            result = self.module.main()
            if result == "EVENTLOOP":
                self.state = EVENTDRIVEN
            else:
                self.state = DONE
        except turtle.Terminator:
            if self.root is None:
                return
            self.state = DONE
            result = "stopped!"
        if self.state == DONE:
            self.configGUI(NORMAL, NORMAL, DISABLED, NORMAL,
                           result)
        elif self.state == EVENTDRIVEN:
            self.exitflag = True
            self.configGUI(DISABLED, DISABLED, NORMAL, DISABLED,
                           "use mouse/keys or STOP", "red")
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def startDemo(self):
        self.refreshCanvas()
        self.dirty = True
        turtle.TurtleScreen._RUNNING = True
        self.configGUI(DISABLED, NORMAL, DISABLED,
                       "demo running...", "black")
        self.screen.clear()
        self.screen.mode("standard")
        self.state = RUNNING

        try:
            result = self.module.main()
            if result == "EVENTLOOP":
                self.state = EVENTDRIVEN
            else:
                self.state = DONE
        except turtle.Terminator:
            if self.root is None:
                return
            self.state = DONE
            result = "stopped!"
        if self.state == DONE:
            self.configGUI(NORMAL, DISABLED, NORMAL,
                           result)
        elif self.state == EVENTDRIVEN:
            self.exitflag = True
            self.configGUI(DISABLED, NORMAL, DISABLED,
                           "use mouse/keys or STOP", "red")
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def startDemo(self):
        self.refreshCanvas()
        self.dirty = True
        turtle.TurtleScreen._RUNNING = True
        self.configGUI(DISABLED, NORMAL, DISABLED,
                       "demo running...", "black")
        self.screen.clear()
        self.screen.mode("standard")
        self.state = RUNNING

        try:
            result = self.module.main()
            if result == "EVENTLOOP":
                self.state = EVENTDRIVEN
            else:
                self.state = DONE
        except turtle.Terminator:
            self.state = DONE
            result = "stopped!"
        if self.state == DONE:
            self.configGUI(NORMAL, DISABLED, NORMAL,
                           result)
        elif self.state == EVENTDRIVEN:
            self.exitflag = True
            self.configGUI(DISABLED, NORMAL, DISABLED,
                           "use mouse/keys or STOP", "red")
项目:jvcprojectortools    作者:arvehj    | 项目源码 | 文件源码
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