diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-01-05 08:49:48 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-05 08:49:48 -0800 |
commit | 6234301bb56a9b388a1c3bf51169a2762ea09172 (patch) | |
tree | 56c597cb971c8efae1cae8effa0d8ecc413532c6 | |
parent | 43fbc70360b2a934ea809b2175d7e99031db2df3 (diff) | |
download | cpython-git-6234301bb56a9b388a1c3bf51169a2762ea09172.tar.gz |
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@udel.edu>
-rw-r--r-- | Lib/tkinter/test/widget_tests.py | 13 | ||||
-rw-r--r-- | Lib/tkinter/ttk.py | 5 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2020-01-03-18-02-50.bpo-39152.JgPjCC.rst | 2 |
3 files changed, 9 insertions, 11 deletions
diff --git a/Lib/tkinter/test/widget_tests.py b/Lib/tkinter/test/widget_tests.py index 75a068fbbf..b42ff52178 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 @@ class AbstractWidgetTest(AbstractTkTest): 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 @@ class AbstractWidgetTest(AbstractTkTest): 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 12f4ac0bd9..52b1a30928 100644 --- a/Lib/tkinter/ttk.py +++ b/Lib/tkinter/ttk.py @@ -1086,11 +1086,12 @@ class Scale(Widget, tkinter.Scale): 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 0000000000..abb3df0da0 --- /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. |