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.
This commit is contained in:
parent
b19c0d77e6
commit
5ea7bb25e3
|
@ -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
|
||||
|
|
|
@ -1084,11 +1084,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):
|
||||
|
|
|
@ -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.
|
Loading…
Reference in New Issue