Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1b3c8f8e
Commit
1b3c8f8e
authored
Aug 01, 2015
by
Terry Jan Reedy
Browse files
Options
Browse Files
Download
Plain Diff
Issue 24745: Merge with 3.4
parents
75b5ab57
d87d1682
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
35 deletions
+51
-35
Lib/idlelib/EditorWindow.py
Lib/idlelib/EditorWindow.py
+3
-14
Lib/idlelib/config-main.def
Lib/idlelib/config-main.def
+1
-1
Lib/idlelib/configDialog.py
Lib/idlelib/configDialog.py
+20
-20
Lib/idlelib/configHandler.py
Lib/idlelib/configHandler.py
+27
-0
No files found.
Lib/idlelib/EditorWindow.py
View file @
1b3c8f8e
...
...
@@ -230,13 +230,7 @@ class EditorWindow(object):
vbar
[
'command'
]
=
text
.
yview
vbar
.
pack
(
side
=
RIGHT
,
fill
=
Y
)
text
[
'yscrollcommand'
]
=
vbar
.
set
fontWeight
=
'normal'
if
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font-bold'
,
type
=
'bool'
):
fontWeight
=
'bold'
text
.
config
(
font
=
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font'
),
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font-size'
,
type
=
'int'
),
fontWeight
))
text
[
'font'
]
=
idleConf
.
GetFont
(
self
.
root
,
'main'
,
'EditorWindow'
)
text_frame
.
pack
(
side
=
LEFT
,
fill
=
BOTH
,
expand
=
1
)
text
.
pack
(
side
=
TOP
,
fill
=
BOTH
,
expand
=
1
)
text
.
focus_set
()
...
...
@@ -797,13 +791,8 @@ class EditorWindow(object):
def
ResetFont
(
self
):
"Update the text widgets' font if it is changed"
# Called from configDialog.py
fontWeight
=
'normal'
if
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font-bold'
,
type
=
'bool'
):
fontWeight
=
'bold'
self
.
text
.
config
(
font
=
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font'
),
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font-size'
,
type
=
'int'
),
fontWeight
))
self
.
text
[
'font'
]
=
idleConf
.
GetFont
(
self
.
root
,
'main'
,
'EditorWindow'
)
def
RemoveKeybindings
(
self
):
"Remove the keybindings before they are changed."
...
...
Lib/idlelib/config-main.def
View file @
1b3c8f8e
...
...
@@ -53,7 +53,7 @@ delete-exitfunc= 1
[EditorWindow]
width= 80
height= 40
font=
courier
font=
TkFixedFont
font-size= 10
font-bold= 0
encoding= none
...
...
Lib/idlelib/configDialog.py
View file @
1b3c8f8e
...
...
@@ -465,9 +465,9 @@ class ConfigDialog(Toplevel):
return
frame
def
AttachVarCallbacks
(
self
):
self
.
fontSize
.
trace_variable
(
'w'
,
self
.
VarChanged_font
Size
)
self
.
fontName
.
trace_variable
(
'w'
,
self
.
VarChanged_font
Name
)
self
.
fontBold
.
trace_variable
(
'w'
,
self
.
VarChanged_font
Bold
)
self
.
fontSize
.
trace_variable
(
'w'
,
self
.
VarChanged_font
)
self
.
fontName
.
trace_variable
(
'w'
,
self
.
VarChanged_font
)
self
.
fontBold
.
trace_variable
(
'w'
,
self
.
VarChanged_font
)
self
.
spaceNum
.
trace_variable
(
'w'
,
self
.
VarChanged_spaceNum
)
self
.
colour
.
trace_variable
(
'w'
,
self
.
VarChanged_colour
)
self
.
builtinTheme
.
trace_variable
(
'w'
,
self
.
VarChanged_builtinTheme
)
...
...
@@ -484,15 +484,15 @@ class ConfigDialog(Toplevel):
self
.
autoSave
.
trace_variable
(
'w'
,
self
.
VarChanged_autoSave
)
self
.
encoding
.
trace_variable
(
'w'
,
self
.
VarChanged_encoding
)
def
VarChanged_font
Size
(
self
,
*
params
):
value
=
self
.
fontSize
.
get
()
self
.
AddChangedItem
(
'main'
,
'EditorWindow'
,
'font-size'
,
value
)
def
VarChanged_fontName
(
self
,
*
params
):
def
VarChanged_font
(
self
,
*
params
):
'''When one font attribute changes, save them all, as they are
not independent from each other. In particular, when we are
overriding the default font, we need to write out everything.
'''
value
=
self
.
fontName
.
get
()
self
.
AddChangedItem
(
'main'
,
'EditorWindow'
,
'font'
,
value
)
def
VarChanged_fontBold
(
self
,
*
params
):
value
=
self
.
fontSize
.
get
()
self
.
AddChangedItem
(
'main'
,
'EditorWindow'
,
'font-size'
,
value
)
value
=
self
.
fontBold
.
get
()
self
.
AddChangedItem
(
'main'
,
'EditorWindow'
,
'font-bold'
,
value
)
...
...
@@ -958,24 +958,24 @@ class ConfigDialog(Toplevel):
fonts
.
sort
()
for
font
in
fonts
:
self
.
listFontName
.
insert
(
END
,
font
)
configuredFont
=
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font'
,
default
=
'courier'
)
lc_configuredFont
=
configuredFont
.
lower
()
self
.
fontName
.
set
(
lc_configuredFont
)
configuredFont
=
idleConf
.
GetFont
(
self
,
'main'
,
'EditorWindow'
)
fontName
=
configuredFont
[
0
].
lower
()
fontSize
=
configuredFont
[
1
]
fontBold
=
configuredFont
[
2
]
==
'bold'
self
.
fontName
.
set
(
fontName
)
lc_fonts
=
[
s
.
lower
()
for
s
in
fonts
]
if
lc_configuredFont
in
lc_fonts
:
currentFontIndex
=
lc_fonts
.
index
(
lc_configuredFont
)
try
:
currentFontIndex
=
lc_fonts
.
index
(
fontName
)
self
.
listFontName
.
see
(
currentFontIndex
)
self
.
listFontName
.
select_set
(
currentFontIndex
)
self
.
listFontName
.
select_anchor
(
currentFontIndex
)
except
ValueError
:
pass
##font size dropdown
fontSize
=
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font-size'
,
type
=
'int'
,
default
=
'10'
)
self
.
optMenuFontSize
.
SetMenu
((
'7'
,
'8'
,
'9'
,
'10'
,
'11'
,
'12'
,
'13'
,
'14'
,
'16'
,
'18'
,
'20'
,
'22'
),
fontSize
)
##fontWeight
self
.
fontBold
.
set
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font-bold'
,
default
=
0
,
type
=
'bool'
))
self
.
fontBold
.
set
(
fontBold
)
##font sample
self
.
SetFontSample
()
...
...
Lib/idlelib/configHandler.py
View file @
1b3c8f8e
...
...
@@ -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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment