[Python-checkins] bpo-39152: add missing ttk.Scale.configure return value (GH-17815)

Miss Islington (bot) webhook-mailer at python.org
Sun Jan 5 11:49:52 EST 2020


https://github.com/python/cpython/commit/6234301bb56a9b388a1c3bf51169a2762ea09172
commit: 6234301bb56a9b388a1c3bf51169a2762ea09172
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-01-05T08:49:48-08:00
summary:

bpo-39152: add missing ttk.Scale.configure return value (GH-17815)


tkinter.ttk.Scale().configure([name]) now returns a configuration tuple for name
or a list thereof for all options. Based on patch Giovanni Lombardo.
(cherry picked from commit 5ea7bb25e3b192d6c49a49c9e3b316f8559602aa)

Co-authored-by: Terry Jan Reedy <tjreedy at udel.edu>

files:
A Misc/NEWS.d/next/Library/2020-01-03-18-02-50.bpo-39152.JgPjCC.rst
M Lib/tkinter/test/widget_tests.py
M Lib/tkinter/ttk.py

diff --git a/Lib/tkinter/test/widget_tests.py b/Lib/tkinter/test/widget_tests.py
index 75a068fbbf26b..b42ff52178f29 100644
--- a/Lib/tkinter/test/widget_tests.py
+++ b/Lib/tkinter/test/widget_tests.py
@@ -3,7 +3,6 @@
 import unittest
 import sys
 import tkinter
-from tkinter.ttk import Scale
 from tkinter.test.support import (AbstractTkTest, tcl_version, requires_tcl,
                                   get_tk_patchlevel, pixels_conv, tcl_obj_eq)
 import test.support
@@ -63,11 +62,9 @@ def checkParam(self, widget, name, value, *, expected=_sentinel,
             eq = tcl_obj_eq
         self.assertEqual2(widget[name], expected, eq=eq)
         self.assertEqual2(widget.cget(name), expected, eq=eq)
-        # XXX
-        if not isinstance(widget, Scale):
-            t = widget.configure(name)
-            self.assertEqual(len(t), 5)
-            self.assertEqual2(t[4], expected, eq=eq)
+        t = widget.configure(name)
+        self.assertEqual(len(t), 5)
+        self.assertEqual2(t[4], expected, eq=eq)
 
     def checkInvalidParam(self, widget, name, value, errmsg=None, *,
                           keep_orig=True):
@@ -209,9 +206,7 @@ def assertIsBoundingBox(self, bbox):
     def test_keys(self):
         widget = self.create()
         keys = widget.keys()
-        # XXX
-        if not isinstance(widget, Scale):
-            self.assertEqual(sorted(keys), sorted(widget.configure()))
+        self.assertEqual(sorted(keys), sorted(widget.configure()))
         for k in keys:
             widget[k]
         # Test if OPTIONS contains all keys
diff --git a/Lib/tkinter/ttk.py b/Lib/tkinter/ttk.py
index 12f4ac0bd9086..52b1a30928c6e 100644
--- a/Lib/tkinter/ttk.py
+++ b/Lib/tkinter/ttk.py
@@ -1086,11 +1086,12 @@ def configure(self, cnf=None, **kw):
 
         Setting a value for any of the "from", "from_" or "to" options
         generates a <<RangeChanged>> event."""
-        if cnf:
+        retval = Widget.configure(self, cnf, **kw)
+        if not isinstance(cnf, (type(None), str)):
             kw.update(cnf)
-        Widget.configure(self, **kw)
         if any(['from' in kw, 'from_' in kw, 'to' in kw]):
             self.event_generate('<<RangeChanged>>')
+        return retval
 
 
     def get(self, x=None, y=None):
diff --git a/Misc/NEWS.d/next/Library/2020-01-03-18-02-50.bpo-39152.JgPjCC.rst b/Misc/NEWS.d/next/Library/2020-01-03-18-02-50.bpo-39152.JgPjCC.rst
new file mode 100644
index 0000000000000..abb3df0da0fe4
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-01-03-18-02-50.bpo-39152.JgPjCC.rst
@@ -0,0 +1,2 @@
+Fix ttk.Scale.configure([name]) to return configuration tuple for name
+or all options.  Giovanni Lombardo contributed part of the patch.



More information about the Python-checkins mailing list