def 清除畫面(self): """ 將龜模組畫布的畫面重設 """ self.screen.clear() self.screen._delete("all") self.scanvas.config(cursor="") self.screen = screen = turtle.Screen() turtle.TurtleScreen.__init__(screen, screen._canvas)
def makeGraphFrame(我, root): turtle._Screen._root = root 我.canvwidth = 1000 我.canvheight = 800 turtle._Screen._canvas = 我._canvas = canvas = turtle.ScrolledCanvas( root, 800, 600, 我.canvwidth, 我.canvheight) canvas.adjustScrolls() canvas._rootwindow.bind('<Configure>', 我.onResize) canvas._canvas['borderwidth'] = 0 我.screen = _s_ = turtle.Screen() turtle.TurtleScreen.__init__(_s_, _s_._canvas) 我.scanvas = _s_._canvas turtle.RawTurtle.screens = [_s_] return canvas
def 建立文字及繪圖區(self): """ 建立兩個Text區跟龜模組畫圖區並建立快捷鍵 """ setup = {} pane = PanedWindow(orient=HORIZONTAL, bg='black') text_frame = Frame(pane) self.text = text = Text(text_frame, name='text', padx=5, wrap='none', width=45, bg='white', tabs="1" * 4, font=tuple(txtfont), undo=True) text.name = "text" vbar = Scrollbar(text_frame, name='vbar') vbar['command'] = text.yview vbar.pack(side=RIGHT, fill=Y) hbar = Scrollbar(text_frame, name='hbar', orient=HORIZONTAL) hbar['command'] = text.xview hbar.pack(side=BOTTOM, fill=X) text['yscrollcommand'] = vbar.set text['xscrollcommand'] = hbar.set text.pack(side=LEFT, fill=BOTH, expand=1) pane.add(text_frame) text_frame2 = Frame(pane) self.text2 = text2 = Text(text_frame2, name='text', padx=5, wrap='none', width=45, bg='white', tabs="1", font=tuple(txtfont), undo=True) text.name = "text2" vbar = Scrollbar(text_frame2, name='vbar') vbar['command'] = text2.yview vbar.pack(side=RIGHT, fill=Y) hbar = Scrollbar(text_frame2, name='hbar', orient=HORIZONTAL) hbar['command'] = text2.xview hbar.pack(side=BOTTOM, fill=X) text2['yscrollcommand'] = vbar.set text2['xscrollcommand'] = hbar.set text2.pack(side=LEFT, fill=BOTH, expand=1) pane.add(text_frame2) self.canvwidth = 800 self.canvheight = 600 turtle._Screen._root = self.root turtle._Screen._canvas = canvas = self._canvas = turtle.ScrolledCanvas( self.root, 800, 600, 1000, 800) canvas.adjustScrolls() canvas._rootwindow.bind('<Configure>', self.onResize) canvas._canvas['borderwidth'] = 0 self.screen = screen = turtle.Screen() turtle.TurtleScreen.__init__(screen, screen._canvas) self.scanvas = scanvas = screen._canvas turtle.RawTurtle.screens = [screen] canvas.pack(side=LEFT, fill=BOTH, expand=1) pane.add(canvas) # for 畫圖 # self.scanvas.bind('<Button-1>',self.焦點轉移) pane.pack(side=TOP, expand=1, fill=BOTH) Percolator(text).insertfilter(ColorDelegator()) Percolator(text2).insertfilter(ColorDelegator()) # text.bind("<Tab>", self.tab) # text2.bind("<Tab>", self.tab) text.bind('<Control-MouseWheel>', self.滑鼠滾輪) text.bind('<Control-Button-4>', self.字體放大) text.bind('<Control-Button-5>', self.字體縮小) text2.bind('<Control-MouseWheel>', self.滑鼠滾輪) text2.bind('<Control-Button-4>', self.字體放大) text2.bind('<Control-Button-5>', self.字體縮小) text.bind('<Button-3>', self.選取標記) text2.bind('<Button-3>', self.選取標記) text.bind("<KeyRelease>", self.行號更新) text.bind("<ButtonRelease>", self.行號更新) text2.bind("<KeyRelease>", self.行號更新) text2.bind("<ButtonRelease>", self.行號更新)