diff -r d0570cba3749 Lib/turtledemo/__main__.py --- a/Lib/turtledemo/__main__.py Sat Jul 26 19:40:16 2014 -0400 +++ b/Lib/turtledemo/__main__.py Sun Jul 27 02:40:02 2014 -0400 @@ -12,6 +12,7 @@ import time demo_dir = os.path.dirname(os.path.abspath(__file__)) +darwin = sys.platform == 'darwin' STARTUP = 1 READY = 2 @@ -21,7 +22,7 @@ menufont = ("Arial", 12, NORMAL) btnfont = ("Arial", 12, 'bold') -txtfont = ('Lucida Console', 8, 'normal') +txtfont = ['Lucida Console', 8, 'normal'] def getExampleEntries(): return [entry[:-3] for entry in os.listdir(demo_dir) if @@ -102,7 +103,7 @@ hbar['command'] = text.xview hbar.pack(side=BOTTOM, fill=X) - text['font'] = txtfont + text['font'] = tuple(txtfont) text['yscrollcommand'] = vbar.set text['xscrollcommand'] = hbar.set text.pack(side=LEFT, fill=BOTH, expand=1) @@ -115,7 +116,7 @@ turtle._Screen._canvas = self._canvas = canvas = turtle.ScrolledCanvas( root, 800, 600, self.canvwidth, self.canvheight) canvas.adjustScrolls() - canvas._rootwindow.bind('', self.onResize) + self._makeBindings(canvas._rootwindow) canvas._canvas['borderwidth'] = 0 self.screen = _s_ = turtle.Screen() @@ -124,6 +125,26 @@ turtle.RawTurtle.screens = [_s_] return canvas + def _makeBindings(self, widget): + shortcut = 'Command' if darwin else 'Control' + widget.bind('', self.onResize) + widget.bind_all('<%s-minus>' % shortcut, self._decreaseFont) + widget.bind_all('<%s-=>' % shortcut, self._increaseFont) + widget.bind_all('<%s-plus>' % shortcut, self._increaseFont) + widget.bind_all('', self._updateFont) + + def _updateFont(self, event): + txtfont[1] += event.delta // (1 if darwin else 120) + self.text['font'] = tuple(txtfont) + + def _decreaseFont(self, dummy): + txtfont[1] -= 1 + self.text['font'] = tuple(txtfont) + + def _increaseFont(self, dummy): + txtfont[1] += 1 + self.text['font'] = tuple(txtfont) + def configGUI(self, menu, start, stop, clear, txt="", color="blue"): self.ExamplesBtn.config(state=menu)