Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 4a3d96c

Browse files
committed
Issue python#24745: Prevent IDLE initialization crash with Tk 8.4:
"TkFixedFont" does not exist in 8.4.
1 parent 131426e commit 4a3d96c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Lib/idlelib/configHandler.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import sys
2323

2424
from configparser import ConfigParser
25+
from tkinter import TkVersion
2526
from tkinter.font import Font, nametofont
2627

2728
class InvalidConfigType(Exception): pass
@@ -688,13 +689,16 @@ def GetFont(self, root, configType, section):
688689
bold = self.GetOption(configType, section, 'font-bold', default=0,
689690
type='bool')
690691
if (family == 'TkFixedFont'):
691-
f = Font(name='TkFixedFont', exists=True, root=root)
692-
actualFont = Font.actual(f)
693-
family = actualFont['family']
694-
size = actualFont['size']
695-
if size < 0:
696-
size = 10 # if font in pixels, ignore actual size
697-
bold = actualFont['weight']=='bold'
692+
if TkVersion < 8.5:
693+
family = 'Courier'
694+
else:
695+
f = Font(name='TkFixedFont', exists=True, root=root)
696+
actualFont = Font.actual(f)
697+
family = actualFont['family']
698+
size = actualFont['size']
699+
if size < 0:
700+
size = 10 # if font in pixels, ignore actual size
701+
bold = actualFont['weight']=='bold'
698702
return (family, size, 'bold' if bold else 'normal')
699703

700704
def LoadCfgFiles(self):

0 commit comments

Comments
 (0)