classification
Title: Add ttk::spinbox to tkinter.ttk
Type: enhancement Stage: resolved
Components: Tkinter Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Alan Moore, ned.deily, serhiy.storchaka, terry.reedy
Priority: normal Keywords: patch

Created on 2018-01-17 17:17 by Alan Moore, last changed 2018-02-11 03:47 by Alan Moore. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 5221 merged python-dev, 2018-01-17 17:26
PR 5592 merged miss-islington, 2018-02-09 00:05
Messages (15)
msg310198 - (view) Author: Alan Moore (Alan Moore) * Date: 2018-01-17 17:17
Ttk has a spinbox widget, which is a themed version of Tkinter spinbox, but this is missing from Python's ttk implementation.
msg310293 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-01-19 22:08
As said in review, I would like to see this added unless there is a good reason for the omission. Still needed are patches for doc and tests.
msg310328 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-01-20 07:42
Needed tests, documentation, etc.
msg311799 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-02-07 19:53
Tests that are failing on my computer:

======================================================================
FAIL: test_command (tkinter.test.test_ttk.test_widgets.SpinboxTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/tkinter/test/test_ttk/test_widgets.py", line 1145, in test_command
    self.assertTrue(success)
AssertionError: [] is not true

======================================================================
FAIL: test_format (tkinter.test.test_ttk.test_widgets.SpinboxTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/tkinter/test/test_ttk/test_widgets.py", line 1199, in test_format
    self.assertEqual(len(value), 10)
AssertionError: 1 != 10

======================================================================
FAIL: test_increment (tkinter.test.test_ttk.test_widgets.SpinboxTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/tkinter/test/test_ttk/test_widgets.py", line 1186, in test_increment
    self.assertEqual(self.spin.get(), '5')
AssertionError: '1' != '5'
- 1
+ 5


======================================================================
FAIL: test_to (tkinter.test.test_ttk.test_widgets.SpinboxTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/tkinter/test/test_ttk/test_widgets.py", line 1163, in test_to
    self.assertEqual(self.spin.get(), '5')
AssertionError: '4' != '5'
- 4
+ 5


======================================================================
FAIL: test_values (tkinter.test.test_ttk.test_widgets.SpinboxTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/tkinter/test/test_ttk/test_widgets.py", line 1248, in test_values
    self.assertEqual(self.spin.get(), '1')
AssertionError: 'a' != '1'
- a
+ 1


======================================================================
FAIL: test_wrap (tkinter.test.test_ttk.test_widgets.SpinboxTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/tkinter/test/test_ttk/test_widgets.py", line 1220, in test_wrap
    self.assertEqual(self.spin.get(), '1')
AssertionError: '10' != '1'
- 10
?  -
+ 1


----------------------------------------------------------------------

This may be a race condition depended on window manager or speed of CPU or GPU.
msg311801 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-02-07 20:34
This is because of HiDPI display. Mouse events are generated with pixel coordinates (x=width - 5, y=5), but these coordinates are out of a button on scaled widget.
msg311802 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-02-07 20:41
If set DPI to low value, the size of a spinbox widget (winfo_width(), winfo_height()) is (185, 20), and the test is passed. If set it to high value, the size is (305, 30), and the test is failed.
msg311803 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-02-07 21:21
I have fixed tests on HiDPI displays. Two issues are left:

1. test_command still fails randomly. Seems adding update_idletasks() invocation fixes this. And calling pack() looks redundant.

2. Following warnings are emitted:

SpinboxTest.OPTIONS doesn't contain "exportselection"
SpinboxTest.OPTIONS doesn't contain "font"
SpinboxTest.OPTIONS doesn't contain "foreground"

Just add these options to the list. Maybe conditionally if they are not supported in 8.5.
msg311807 - (view) Author: Alan Moore (Alan Moore) * Date: 2018-02-07 21:58
Thanks, I'm guessing  the update_idletasks() needed to be called after 
changing the value of command, since the button clicks do this as part 
of the method. If that's not right, let me know.

I've added the options to the list and pushed the changes to the PR.

On 02/07/2018 03:21 PM, Serhiy Storchaka wrote:
> Serhiy Storchaka <storchaka+cpython@gmail.com> added the comment:
>
> I have fixed tests on HiDPI displays. Two issues are left:
>
> 1. test_command still fails randomly. Seems adding update_idletasks() invocation fixes this. And calling pack() looks redundant.
>
> 2. Following warnings are emitted:
>
> SpinboxTest.OPTIONS doesn't contain "exportselection"
> SpinboxTest.OPTIONS doesn't contain "font"
> SpinboxTest.OPTIONS doesn't contain "foreground"
>
> Just add these options to the list. Maybe conditionally if they are not supported in 8.5.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue32585>
> _______________________________________
>
msg311830 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-02-08 13:30
All tests are passed.

Ned, is it possible to get this feature in 3.7? I didn't have possibility to merge it before 3.7b1. This is just an addition of a simple class. It should be added years ago, it was not added before just due to oversight. This doesn't affect any other code, but may be used in future enhancements of IDLE.
msg311853 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-02-08 21:56
It is past the feature code cutoff for 3.7.0 but the risks seem low and the benefit reasonably high.  Please make sure it is merged ASAP to allow time for buildbot exposure, etc, prior to 370b2.
msg311856 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-02-09 00:03
New changeset a48e78a0b7761dd74f1d03fc69e0f6caa6f02fe6 by Serhiy Storchaka (Alan D Moore) in branch 'master':
bpo-32585: Add tkinter.ttk.Spinbox. (#5221)
https://github.com/python/cpython/commit/a48e78a0b7761dd74f1d03fc69e0f6caa6f02fe6
msg311857 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-02-09 00:04
Thank you Ned.
msg311879 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-02-09 11:40
New changeset 105fcbfd6a91abea0ecd71e53651f39ad6f6039b by Serhiy Storchaka (Miss Islington (bot)) in branch '3.7':
bpo-32585: Add tkinter.ttk.Spinbox. (GH-5221) (GH-5592)
https://github.com/python/cpython/commit/105fcbfd6a91abea0ecd71e53651f39ad6f6039b
msg311880 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-02-09 11:41
Thank you for your contribution Alan!
msg311979 - (view) Author: Alan Moore (Alan Moore) * Date: 2018-02-11 03:47
Thank you for all your help!

On 02/09/2018 05:41 AM, Serhiy Storchaka wrote:
> Serhiy Storchaka <storchaka+cpython@gmail.com> added the comment:
>
> Thank you for your contribution Alan!
>
> ----------
> resolution:  -> fixed
> stage: patch review -> resolved
> status: open -> closed
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue32585>
> _______________________________________
>
History
Date User Action Args
2018-02-11 03:47:07Alan Mooresetmessages: + msg311979
2018-02-09 11:41:16serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg311880

stage: patch review -> resolved
2018-02-09 11:40:16serhiy.storchakasetmessages: + msg311879
2018-02-09 00:05:07miss-islingtonsetstage: commit review -> patch review
pull_requests: + pull_request5410
2018-02-09 00:04:46serhiy.storchakasetmessages: + msg311857
2018-02-09 00:03:57serhiy.storchakasetmessages: + msg311856
2018-02-08 21:56:44ned.deilysetstage: test needed -> commit review
messages: + msg311853
versions: + Python 3.8
2018-02-08 13:30:47serhiy.storchakasetnosy: + ned.deily
messages: + msg311830
2018-02-07 21:58:16Alan Mooresetmessages: + msg311807
2018-02-07 21:21:01serhiy.storchakasetmessages: + msg311803
2018-02-07 20:41:03serhiy.storchakasetmessages: + msg311802
2018-02-07 20:34:18serhiy.storchakasetmessages: + msg311801
2018-02-07 19:53:02serhiy.storchakasetmessages: + msg311799
2018-01-20 07:42:13serhiy.storchakasetmessages: + msg310328
2018-01-19 22:08:54terry.reedysetnosy: + terry.reedy, serhiy.storchaka

messages: + msg310293
stage: patch review -> test needed
2018-01-17 17:26:28python-devsetkeywords: + patch
stage: patch review
pull_requests: + pull_request5072
2018-01-17 17:17:11Alan Moorecreate