[Python-checkins] bpo-34548: IDLE: use configured theme colors in TextView (GH-9008)

Miss Islington (bot) webhook-mailer at python.org
Sun Sep 23 09:31:54 EDT 2018


https://github.com/python/cpython/commit/6b48f9854e2ae35fd74bcd359451eb37ae65f798
commit: 6b48f9854e2ae35fd74bcd359451eb37ae65f798
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-09-23T06:31:51-07:00
summary:

bpo-34548: IDLE: use configured theme colors in TextView (GH-9008)


https://bugs.python.org/issue34548
(cherry picked from commit c87d9f406bb23657c1b4cd63017bb7bd7693a1fb)

Co-authored-by: Tal Einat <taleinat+github at gmail.com>

files:
A Misc/NEWS.d/next/IDLE/2018-09-22-20-25-07.bpo-34548.7pBzjg.rst
M Lib/idlelib/colorizer.py
M Lib/idlelib/textview.py

diff --git a/Lib/idlelib/colorizer.py b/Lib/idlelib/colorizer.py
index 58cced249ac2..f2de9fc45515 100644
--- a/Lib/idlelib/colorizer.py
+++ b/Lib/idlelib/colorizer.py
@@ -31,11 +31,12 @@ def make_pat():
 prog = re.compile(make_pat(), re.S)
 idprog = re.compile(r"\s+(\w+)", re.S)
 
-def color_config(text):  # Called from htest, Editor, and Turtle Demo.
-    '''Set color opitons of Text widget.
+def color_config(text):
+    """Set color options of Text widget.
 
-    Should be called whenever ColorDelegator is called.
-    '''
+    If ColorDelegator is used, this should be called first.
+    """
+    # Called from htest, TextFrame, Editor, and Turtledemo.
     # Not automatic because ColorDelegator does not know 'text'.
     theme = idleConf.CurrentTheme()
     normal_colors = idleConf.GetHighlight(theme, 'normal')
@@ -50,6 +51,7 @@ def color_config(text):  # Called from htest, Editor, and Turtle Demo.
         inactiveselectbackground=select_colors['background'],  # new in 8.5
     )
 
+
 class ColorDelegator(Delegator):
 
     def __init__(self):
@@ -285,6 +287,7 @@ def _color_delegator(parent):  # htest #
     d = ColorDelegator()
     p.insertfilter(d)
 
+
 if __name__ == "__main__":
     from unittest import main
     main('idlelib.idle_test.test_colorizer', verbosity=2, exit=False)
diff --git a/Lib/idlelib/textview.py b/Lib/idlelib/textview.py
index 75b24703b4c3..464e6ac6b94e 100644
--- a/Lib/idlelib/textview.py
+++ b/Lib/idlelib/textview.py
@@ -5,6 +5,8 @@
 from tkinter.ttk import Frame, Scrollbar, Button
 from tkinter.messagebox import showerror
 
+from idlelib.colorizer import color_config
+
 
 class TextFrame(Frame):
     "Display text with scrollbar."
@@ -18,12 +20,9 @@ def __init__(self, parent, rawtext):
         super().__init__(parent)
         self['relief'] = 'sunken'
         self['height'] = 700
-        # TODO: get fg/bg from theme.
-        self.bg = '#ffffff'
-        self.fg = '#000000'
 
-        self.text = text = Text(self, wrap='word', highlightthickness=0,
-                                fg=self.fg, bg=self.bg)
+        self.text = text = Text(self, wrap='word', highlightthickness=0)
+        color_config(text)
         self.scroll = scroll = Scrollbar(self, orient='vertical',
                                          takefocus=False, command=text.yview)
         text['yscrollcommand'] = scroll.set
diff --git a/Misc/NEWS.d/next/IDLE/2018-09-22-20-25-07.bpo-34548.7pBzjg.rst b/Misc/NEWS.d/next/IDLE/2018-09-22-20-25-07.bpo-34548.7pBzjg.rst
new file mode 100644
index 000000000000..237c0c788c2c
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2018-09-22-20-25-07.bpo-34548.7pBzjg.rst
@@ -0,0 +1 @@
+Use configured color theme for read-only text views.



More information about the Python-checkins mailing list