Issue #24745: Prevent IDLE initialization crash with Tk 8.4:

"TkFixedFont" does not exist in 8.4.
This commit is contained in:
Ned Deily 2015-08-09 23:21:29 -04:00
parent 131426ebe3
commit 4a3d96cafb
1 changed files with 11 additions and 7 deletions

View File

@ -22,6 +22,7 @@ import os
import sys import sys
from configparser import ConfigParser from configparser import ConfigParser
from tkinter import TkVersion
from tkinter.font import Font, nametofont from tkinter.font import Font, nametofont
class InvalidConfigType(Exception): pass class InvalidConfigType(Exception): pass
@ -688,13 +689,16 @@ class IdleConf:
bold = self.GetOption(configType, section, 'font-bold', default=0, bold = self.GetOption(configType, section, 'font-bold', default=0,
type='bool') type='bool')
if (family == 'TkFixedFont'): if (family == 'TkFixedFont'):
f = Font(name='TkFixedFont', exists=True, root=root) if TkVersion < 8.5:
actualFont = Font.actual(f) family = 'Courier'
family = actualFont['family'] else:
size = actualFont['size'] f = Font(name='TkFixedFont', exists=True, root=root)
if size < 0: actualFont = Font.actual(f)
size = 10 # if font in pixels, ignore actual size family = actualFont['family']
bold = actualFont['weight']=='bold' 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') return (family, size, 'bold' if bold else 'normal')
def LoadCfgFiles(self): def LoadCfgFiles(self):