Skip to content

Commit 8675799

Browse files
committed
De-'colour'ize stdlib except for idlelib.configDialog.
Tweak docstrigs and comments in affected functions in idlelib.configHandler.
1 parent 5bd6242 commit 8675799

5 files changed

Lines changed: 25 additions & 23 deletions

File tree

Lib/idlelib/EditorWindow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ def _rmcolorizer(self):
766766
self.color = None
767767

768768
def ResetColorizer(self):
769-
"Update the colour theme"
769+
"Update the color theme"
770770
# Called from self.filename_change_hook and from configDialog.py
771771
self._rmcolorizer()
772772
self._addcolorizer()

Lib/idlelib/configHandler.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -274,25 +274,27 @@ def GetSectionList(self, configSet, configType):
274274
return cfgParser.sections()
275275

276276
def GetHighlight(self, theme, element, fgBg=None):
277-
"""Return individual highlighting theme elements.
277+
"""Return individual theme element highlight color(s).
278278
279-
fgBg - string ('fg'or'bg') or None, if None return a dictionary
280-
containing fg and bg colours (appropriate for passing to Tkinter in,
281-
e.g., a tag_config call), otherwise fg or bg colour only as specified.
279+
fgBg - string ('fg' or 'bg') or None.
280+
If None, return a dictionary containing fg and bg colors with
281+
keys 'foreground' and 'background'. Otherwise, only return
282+
fg or bg color, as specified. Colors are intended to be
283+
appropriate for passing to Tkinter in, e.g., a tag_config call).
282284
"""
283285
if self.defaultCfg['highlight'].has_section(theme):
284286
themeDict = self.GetThemeDict('default', theme)
285287
else:
286288
themeDict = self.GetThemeDict('user', theme)
287289
fore = themeDict[element + '-foreground']
288-
if element == 'cursor': #there is no config value for cursor bg
290+
if element == 'cursor': # There is no config value for cursor bg
289291
back = themeDict['normal-background']
290292
else:
291293
back = themeDict[element + '-background']
292294
highlight = {"foreground": fore, "background": back}
293-
if not fgBg: #return dict of both colours
295+
if not fgBg: # Return dict of both colors
294296
return highlight
295-
else: #return specified colour only
297+
else: # Return specified color only
296298
if fgBg == 'fg':
297299
return highlight["foreground"]
298300
if fgBg == 'bg':
@@ -314,11 +316,11 @@ def GetThemeDict(self, type, themeName):
314316
cfgParser = self.defaultCfg['highlight']
315317
else:
316318
raise InvalidTheme('Invalid theme type specified')
317-
#foreground and background values are provded for each theme element
318-
#(apart from cursor) even though all these values are not yet used
319-
#by idle, to allow for their use in the future. Default values are
320-
#generally black and white.
321-
# TODO make theme, a constant, a module or class attribute
319+
# Provide foreground and background colors for each theme
320+
# element (other than cursor) even though some values are not
321+
# yet used by idle, to allow for their use in the future.
322+
# Default values are generally black and white.
323+
# TODO copy theme from a class attribute.
322324
theme ={'normal-foreground':'#000000',
323325
'normal-background':'#ffffff',
324326
'keyword-foreground':'#000000',
@@ -350,18 +352,18 @@ def GetThemeDict(self, type, themeName):
350352
'console-background':'#ffffff' }
351353
for element in theme:
352354
if not cfgParser.has_option(themeName, element):
353-
#we are going to return a default, print warning
354-
warning = ('\n Warning: configHandler.py - IdleConf.GetThemeDict'
355+
# Print warning that will return a default color
356+
warning = ('\n Warning: configHandler.IdleConf.GetThemeDict'
355357
' -\n problem retrieving theme element %r'
356358
'\n from theme %r.\n'
357-
' returning default value: %r' %
359+
' returning default color: %r' %
358360
(element, themeName, theme[element]))
359361
try:
360362
print(warning, file=sys.stderr)
361363
except OSError:
362364
pass
363-
colour = cfgParser.Get(themeName, element, default=theme[element])
364-
theme[element] = colour
365+
theme[element] = cfgParser.Get(
366+
themeName, element, default=theme[element])
365367
return theme
366368

367369
def CurrentTheme(self):

Lib/tkinter/colorchooser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# tk common colour chooser dialogue
1+
# tk common color chooser dialogue
22
#
33
# this module provides an interface to the native color dialogue
44
# available in Tk 4.2 and newer.
@@ -11,7 +11,7 @@
1111
#
1212
# options (all have default values):
1313
#
14-
# - initialcolor: colour to mark as selected when dialog is displayed
14+
# - initialcolor: color to mark as selected when dialog is displayed
1515
# (given as an RGB triplet or a Tk color string)
1616
#
1717
# - parent: which window to place the dialog on top of

Lib/turtledemo/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
(1) How to use the demo viewer.
1515
1616
Select a demoscript from the example menu.
17-
The (syntax coloured) source code appears in the left
17+
The (syntax colored) source code appears in the left
1818
source code window. IT CANNOT BE EDITED, but ONLY VIEWED!
1919
2020
The demo viewer windows can be resized. The divider between text

Lib/turtledemo/chaos.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def coosys():
2929
line(-1, 0, N+1, 0)
3030
line(0, -0.1, 0, 1.1)
3131

32-
def plot(fun, start, colour):
33-
pencolor(colour)
32+
def plot(fun, start, color):
33+
pencolor(color)
3434
x = start
3535
jumpto(0, x)
3636
pendown()

0 commit comments

Comments
 (0)