Skip to content

bpo-39107: Updated Tcl and Tk to 8.6.10 in Windows installer #22405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 19, 2020
Merged

Conversation

zooba
Copy link
Member

@zooba zooba commented Sep 24, 2020

On Windows tk 8.6.10, tk Scale no longer rounds 'from',
thus matching ttk Scale behavior.
@terryjreedy
Copy link
Member

terryjreedy commented Sep 25, 2020

I verified that the only failure is in test.test_tk:

FAIL: test_from (tkinter.test.test_tkinter.test_widgets.ScaleTest)
Traceback (most recent call last):
File "f:\dev\3x\lib\tkinter\test\test_tkinter\test_widgets.py", line 943, in test_from
self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=float_round)
File "f:\dev\3x\lib\tkinter\test\widget_tests.py", line 106, in checkFloatParam
self.checkParam(widget, name, value, conv=conv, **kwargs)
File "f:\dev\3x\lib\tkinter\test\widget_tests.py", line 63, in checkParam
self.assertEqual2(widget[name], expected, eq=eq)
File "f:\dev\3x\lib\tkinter\test\widget_tests.py", line 47, in assertEqual2
self.assertEqual(actual, expected, msg)
AssertionError: 14.9 != 15.0

The other 3 tkinter test files, test_idle, and test_turtle run OK.

The reason is that on Windows, tkinter.Scale['from'] was 'fixed' to match the behavior of tkinter.ttk.Scale.

In 3.9:

>>> import tkinter as tk
>>> r = tk.Tk()
>>> s = tk.Scale(r, from_=14.9)
>>> s.pack()
>>> s['from']
15.0
>>> from tkinter import ttk
>>> sk = ttk.Scale(r, from_=14.9)
>>> sk['from']
14.9

So test_from for tk and ttk respectively use float_round() = float(round()) and False.
self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=self.float_round)
self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=False)

In 8.6.10, s['from'] is 14.9 for tk.Scale also. So on Windows, conv should be False.

For tk.Scale, s['to'] is adjusted according to the s['from'], so if 'from' is left as the default 0.0, 14.9 and 15.1 are adjusted to 15.0. This is not true for ttk.Scale. Anyway, since test_to passes, we leave it alone.

Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About IDLE shows 3.6.10 and the existing automated tests now pass.

@@ -940,7 +940,8 @@ def test_digits(self):

def test_from(self):
widget = self.create()
self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=float_round)
cvt = False if sys.platform == 'win32' else float_round # 39107
Copy link
Member

@serhiy-storchaka serhiy-storchaka Sep 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should depend not on platform, but on Tk version. Use get_tk_patchlevel().

Also, it would be better to use name conv instead of cvt for consistency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. However, I could not fine that name in either tkinter or _tkinter, so I used the tk call used in idlelib.help_about. I used an equality check. But it would not work for an 8.6.11. Is such possible?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_tk_patchlevel is defined in tkinter.test.support and is already imported in this file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serhiy, do you prefer passing False, as the ttk Scale test does, or 'noconv', as in #21715?
Do you want a comment added, such as in the other PR?
Please decide whether you want to close the other issue and PR or merge it and remove the test change here.
Either way, I would like to get this merged so we can routinely test tkinter and IDLE on Windows with 8.6.10 in place.

@bedevere-bot
Copy link

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@zooba
Copy link
Member Author

zooba commented Sep 28, 2020

@serhiy-storchaka Looks like we're waiting on you - any further comment?

@zooba zooba merged commit 985f0ab into master Oct 19, 2020
@zooba zooba deleted the bpo-39107 branch October 19, 2020 15:55
@52LY
Copy link

52LY commented Mar 5, 2021

I verified that the only failure is in test.test_tk:

FAIL: test_from (tkinter.test.test_tkinter.test_widgets.ScaleTest)
Traceback (most recent call last):
File "f:\dev\3x\lib\tkinter\test\test_tkinter\test_widgets.py", line 943, in test_from
self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=float_round)
File "f:\dev\3x\lib\tkinter\test\widget_tests.py", line 106, in checkFloatParam
self.checkParam(widget, name, value, conv=conv, **kwargs)
File "f:\dev\3x\lib\tkinter\test\widget_tests.py", line 63, in checkParam
self.assertEqual2(widget[name], expected, eq=eq)
File "f:\dev\3x\lib\tkinter\test\widget_tests.py", line 47, in assertEqual2
self.assertEqual(actual, expected, msg)
AssertionError: 14.9 != 15.0

The other 3 tkinter test files, test_idle, and test_turtle run OK.

The reason is that on Windows, tkinter.Scale['from'] was 'fixed' to match the behavior of tkinter.ttk.Scale.

In 3.9:

>>> import tkinter as tk
>>> r = tk.Tk()
>>> s = tk.Scale(r, from_=14.9)
>>> s.pack()
>>> s['from']
15.0
>>> from tkinter import ttk
>>> sk = ttk.Scale(r, from_=14.9)
>>> sk['from']
14.9

So test_from for tk and ttk respectively use float_round() = float(round()) and False.
self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=self.float_round)
self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=False)

In 8.6.10, s['from'] is 14.9 for tk.Scale also. So on Windows, conv should be False.

For tk.Scale, s['to'] is adjusted according to the s['from'], so if 'from' is left as the default 0.0, 14.9 and 15.1 are adjusted to 15.0. This is not true for ttk.Scale. Anyway, since test_to passes, we leave it alone.

s[''resolution'] = 0.1
s['from_'] = 15.9
s['from_']
15.900000000000002
default, s[''resolution']=1, so 15.9 ==> 16, 15.5 ==> 16, 15.49 ==> 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants