Skip to content
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

Add ttk::spinbox to tkinter.ttk #76766

Closed
alandmoore mannequin opened this issue Jan 17, 2018 · 15 comments
Closed

Add ttk::spinbox to tkinter.ttk #76766

alandmoore mannequin opened this issue Jan 17, 2018 · 15 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes topic-tkinter type-feature A feature request or enhancement

Comments

@alandmoore
Copy link
Mannequin

alandmoore mannequin commented Jan 17, 2018

BPO 32585
Nosy @terryjreedy, @ned-deily, @serhiy-storchaka, @alandmoore
PRs
  • bpo-32585: Add ttk::spinbox #5221
  • [3.7] bpo-32585: Add tkinter.ttk.Spinbox. (GH-5221) #5592
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2018-02-09.11:41:16.048>
    created_at = <Date 2018-01-17.17:17:11.517>
    labels = ['3.7', '3.8', 'type-feature', 'expert-tkinter']
    title = 'Add ttk::spinbox to tkinter.ttk'
    updated_at = <Date 2018-02-11.03:47:07.313>
    user = 'https://github.com/alandmoore'

    bugs.python.org fields:

    activity = <Date 2018-02-11.03:47:07.313>
    actor = 'Alan Moore'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-02-09.11:41:16.048>
    closer = 'serhiy.storchaka'
    components = ['Tkinter']
    creation = <Date 2018-01-17.17:17:11.517>
    creator = 'Alan Moore'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32585
    keywords = ['patch']
    message_count = 15.0
    messages = ['310198', '310293', '310328', '311799', '311801', '311802', '311803', '311807', '311830', '311853', '311856', '311857', '311879', '311880', '311979']
    nosy_count = 4.0
    nosy_names = ['terry.reedy', 'ned.deily', 'serhiy.storchaka', 'Alan Moore']
    pr_nums = ['5221', '5592']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue32585'
    versions = ['Python 3.7', 'Python 3.8']

    @alandmoore
    Copy link
    Mannequin Author

    alandmoore mannequin commented Jan 17, 2018

    Ttk has a spinbox widget, which is a themed version of Tkinter spinbox, but this is missing from Python's ttk implementation.

    @alandmoore alandmoore mannequin added 3.7 (EOL) end of life topic-tkinter type-feature A feature request or enhancement labels Jan 17, 2018
    @terryjreedy
    Copy link
    Member

    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.

    @serhiy-storchaka
    Copy link
    Member

    Needed tests, documentation, etc.

    @serhiy-storchaka
    Copy link
    Member

    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.

    @serhiy-storchaka
    Copy link
    Member

    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.

    @serhiy-storchaka
    Copy link
    Member

    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.

    @serhiy-storchaka
    Copy link
    Member

    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.

    @alandmoore
    Copy link
    Mannequin Author

    alandmoore mannequin commented Feb 7, 2018

    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\>


    @serhiy-storchaka
    Copy link
    Member

    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.

    @ned-deily
    Copy link
    Member

    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.

    @ned-deily ned-deily added the 3.8 only security fixes label Feb 8, 2018
    @serhiy-storchaka
    Copy link
    Member

    New changeset a48e78a by Serhiy Storchaka (Alan D Moore) in branch 'master':
    bpo-32585: Add tkinter.ttk.Spinbox. (bpo-5221)
    a48e78a

    @serhiy-storchaka
    Copy link
    Member

    Thank you Ned.

    @serhiy-storchaka
    Copy link
    Member

    New changeset 105fcbf by Serhiy Storchaka (Miss Islington (bot)) in branch '3.7':
    bpo-32585: Add tkinter.ttk.Spinbox. (GH-5221) (GH-5592)
    105fcbf

    @serhiy-storchaka
    Copy link
    Member

    Thank you for your contribution Alan!

    @alandmoore
    Copy link
    Mannequin Author

    alandmoore mannequin commented Feb 11, 2018

    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\>


    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes topic-tkinter type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants