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

Miss Islington (bot) webhook-mailer at python.org
Sun Jan 5 12:07:37 EST 2020

commit: 636a850ed81cf9b8feed523f277b1538bfc5230b
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-01-05T09:07:30-08:00

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>

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, *,
@@ -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:
         # Test if OPTIONS contains all keys
diff --git a/Lib/tkinter/ttk.py b/Lib/tkinter/ttk.py
index 573544dd84a39..c7c71cd5a559c 100644
--- a/Lib/tkinter/ttk.py
+++ b/Lib/tkinter/ttk.py
@@ -1084,11 +1084,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)):
-        Widget.configure(self, **kw)
         if any(['from' in kw, 'from_' in kw, 'to' in kw]):
+        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