Skip to content
Permalink
Browse files

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.
  • Loading branch information
terryjreedy committed Jan 5, 2020
1 parent b19c0d7 commit 5ea7bb25e3b192d6c49a49c9e3b316f8559602aa
Showing with 9 additions and 11 deletions.
  1. +4 βˆ’9 Lib/tkinter/test/widget_tests.py
  2. +3 βˆ’2 Lib/tkinter/ttk.py
  3. +2 βˆ’0 Misc/NEWS.d/next/Library/2020-01-03-18-02-50.bpo-39152.JgPjCC.rst
@@ -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
@@ -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)):
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):
@@ -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.

0 comments on commit 5ea7bb2

Please sign in to comment.
You can’t perform that action at this time.