jenkins-bot merged this change.

View Change

Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
[bugfix] Fix gui settings

fgBg parameter of idlelib.config.GetHighlight()
has been removed in Python 3.8 and patch was
backported in Python 3.7.4
https://bugs.python.org/issue36396

initialize config setting in new TextEditor._initialize_config method
in a propper way for different Python releases

Bug: T241216
Change-Id: Ic1fab461df06ca22f9cbcad585e7dfd51343b70f
---
M pywikibot/userinterfaces/gui.py
1 file changed, 43 insertions(+), 24 deletions(-)

diff --git a/pywikibot/userinterfaces/gui.py b/pywikibot/userinterfaces/gui.py
index 04c256c..792af43 100644
--- a/pywikibot/userinterfaces/gui.py
+++ b/pywikibot/userinterfaces/gui.py
@@ -58,36 +58,55 @@

Get default settings from user's IDLE configuration.
"""
- currentTheme = idleConf.CurrentTheme()
- textcf = {
- 'padx': 5,
- 'wrap': 'word',
- 'undo': 'True',
- 'foreground': idleConf.GetHighlight(
- currentTheme, 'normal', fgBg='fg'),
- 'background': idleConf.GetHighlight(
- currentTheme, 'normal', fgBg='bg'),
- 'highlightcolor': idleConf.GetHighlight(
- currentTheme, 'hilite', fgBg='fg'),
- 'highlightbackground': idleConf.GetHighlight(
- currentTheme, 'hilite', fgBg='bg'),
- 'insertbackground': idleConf.GetHighlight(
- currentTheme, 'cursor', fgBg='fg'),
- 'width': idleConf.GetOption('main', 'EditorWindow', 'width'),
- 'height': idleConf.GetOption('main', 'EditorWindow', 'height'),
- }
- fontWeight = 'normal'
+ textcf = self._initialize_config(idleConf.CurrentTheme())
+
if idleConf.GetOption('main', 'EditorWindow', 'font-bold',
type='bool'):
- fontWeight = 'bold'
- textcf['font'] = (idleConf.GetOption('main', 'EditorWindow', 'font'),
- idleConf.GetOption('main', 'EditorWindow',
- 'font-size'),
- fontWeight)
+ font_weight = 'bold'
+ else:
+ font_weight = 'normal'
+ textcf['font'] = (
+ idleConf.GetOption('main', 'EditorWindow', 'font'),
+ idleConf.GetOption('main', 'EditorWindow', 'font-size'),
+ font_weight)
+
# override defaults with any user-specified settings
textcf.update(kwargs)
ScrolledText.__init__(self, master, **textcf)

+ def _initialize_config(self, Theme):
+ """Fix idleConf.GetHighlight method for different Python releases."""
+ config = {
+ 'padx': 5,
+ 'wrap': 'word',
+ 'undo': 'True',
+ 'width': idleConf.GetOption('main', 'EditorWindow', 'width'),
+ 'height': idleConf.GetOption('main', 'EditorWindow', 'height'),
+ }
+ if PYTHON_VERSION >= (3, 7, 4): # T241216
+ config['foreground'] = idleConf.GetHighlight(
+ Theme, 'normal')['foreground']
+ config['background'] = idleConf.GetHighlight(
+ Theme, 'normal')['background']
+ config['highlightcolor'] = idleConf.GetHighlight(
+ Theme, 'hilite')['foreground']
+ config['highlightbackground'] = idleConf.GetHighlight(
+ Theme, 'hilite')['background']
+ config['insertbackground'] = idleConf.GetHighlight(
+ Theme, 'cursor')['foreground']
+ else:
+ config['foreground'] = idleConf.GetHighlight(
+ Theme, 'normal', fgBg='fg')
+ config['background'] = idleConf.GetHighlight(
+ Theme, 'normal', fgBg='bg')
+ config['highlightcolor'] = idleConf.GetHighlight(
+ Theme, 'hilite', fgBg='fg')
+ config['highlightbackground'] = idleConf.GetHighlight(
+ Theme, 'hilite', fgBg='bg')
+ config['insertbackground'] = idleConf.GetHighlight(
+ Theme, 'cursor', fgBg='fg')
+ return config
+
def add_bindings(self):
"""Assign key and events bindings to methods."""
# due to IDLE dependencies, this can't be called from __init__

To view, visit change 559760. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic1fab461df06ca22f9cbcad585e7dfd51343b70f
Gerrit-Change-Number: 559760
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: Eflyjason <eflyjason@gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki@gmail.com>
Gerrit-Reviewer: jenkins-bot (75)