diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2015-08-01 22:57:27 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2015-08-01 22:57:27 (GMT) |
commit | 1235214945c72e7e0193cdbf3a89da7cff02f1af (patch) | |
tree | 658abbb1ddf71e35b860eeac810d31e7d019fcf1 /Lib/idlelib/configHandler.py | |
parent | 3f32b979d5de5db2e07359502797e1a0e7e7cd1c (diff) | |
download | cpython-1235214945c72e7e0193cdbf3a89da7cff02f1af.zip cpython-1235214945c72e7e0193cdbf3a89da7cff02f1af.tar.gz cpython-1235214945c72e7e0193cdbf3a89da7cff02f1af.tar.bz2 |
Issue 24745: Switch from Courier to platform-sensitive TkFixedFont as default
editor font. This should not affect current customized font selections.
Patch by Mark Roseman.
Diffstat (limited to 'Lib/idlelib/configHandler.py')
-rw-r--r-- | Lib/idlelib/configHandler.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py index 646660a..c9ec9c3 100644 --- a/Lib/idlelib/configHandler.py +++ b/Lib/idlelib/configHandler.py @@ -23,6 +23,7 @@ import os import sys from ConfigParser import ConfigParser +from tkFont import Font, nametofont class InvalidConfigType(Exception): pass class InvalidConfigSet(Exception): pass @@ -671,6 +672,32 @@ class IdleConf: self.GetExtraHelpSourceList('user') ) return allHelpSources + def GetFont(self, root, configType, section): + """Retrieve a font from configuration (font, font-size, font-bold) + Intercept the special value 'TkFixedFont' and substitute + the actual font, factoring in some tweaks if needed for + appearance sakes. + + The 'root' parameter can normally be any valid Tkinter widget. + + Return a tuple (family, size, weight) suitable for passing + to tkinter.Font + """ + family = self.GetOption(configType, section, 'font', default='courier') + size = self.GetOption(configType, section, 'font-size', type='int', + default='10') + bold = self.GetOption(configType, section, 'font-bold', default=0, + type='bool') + if (family == 'TkFixedFont'): + f = Font(name='TkFixedFont', exists=True, root=root) + actualFont = Font.actual(f) + family = actualFont['family'] + size = actualFont['size'] + if size < 0: + size = 10 # if font in pixels, ignore actual size + bold = actualFont['weight']=='bold' + return (family, size, 'bold' if bold else 'normal') + def LoadCfgFiles(self): "Load all configuration files." for key in self.defaultCfg: |