diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2015-08-01 22:58:23 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2015-08-01 22:58:23 (GMT) |
commit | 1b3c8f8eec8bab568362be80e1df624a591e69c4 (patch) | |
tree | c9ed728b62e2efa7a0ff55ec8e531df1e38fdc47 /Lib/idlelib/configHandler.py | |
parent | 75b5ab5770ea0604b50ab21852749dba199e4fab (diff) | |
parent | d87d16826ac55f260b706cb63d8ee0a7d3c6d893 (diff) | |
download | cpython-1b3c8f8eec8bab568362be80e1df624a591e69c4.zip cpython-1b3c8f8eec8bab568362be80e1df624a591e69c4.tar.gz cpython-1b3c8f8eec8bab568362be80e1df624a591e69c4.tar.bz2 |
Issue 24745: Merge with 3.4
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 b94b8f1..db3bcbc 100644 --- a/Lib/idlelib/configHandler.py +++ b/Lib/idlelib/configHandler.py @@ -22,6 +22,7 @@ import os import sys from configparser import ConfigParser +from tkinter.font import Font, nametofont class InvalidConfigType(Exception): pass class InvalidConfigSet(Exception): pass @@ -670,6 +671,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: |