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

Tkinter mainloop raises when setting the value of ttk.LabeledScale #72126

Closed
goyodiaz mannequin opened this issue Sep 2, 2016 · 3 comments
Closed

Tkinter mainloop raises when setting the value of ttk.LabeledScale #72126

goyodiaz mannequin opened this issue Sep 2, 2016 · 3 comments
Assignees
Labels
3.7 (EOL) end of life topic-tkinter type-bug An unexpected behavior, bug, or error

Comments

@goyodiaz
Copy link
Mannequin

goyodiaz mannequin commented Sep 2, 2016

BPO 27939
Nosy @serhiy-storchaka
PRs
  • [Do Not Merge] Convert Misc/NEWS so that it is managed by towncrier #552
  • Files
  • tkinter_intvar_float_value.patch
  • 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 = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2016-10-30.16:53:56.916>
    created_at = <Date 2016-09-02.10:20:34.545>
    labels = ['3.7', 'type-bug', 'expert-tkinter']
    title = 'Tkinter mainloop raises when setting the value of ttk.LabeledScale'
    updated_at = <Date 2017-03-31.16:36:26.919>
    user = 'https://bugs.python.org/goyodiaz'

    bugs.python.org fields:

    activity = <Date 2017-03-31.16:36:26.919>
    actor = 'dstufft'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2016-10-30.16:53:56.916>
    closer = 'serhiy.storchaka'
    components = ['Tkinter']
    creation = <Date 2016-09-02.10:20:34.545>
    creator = 'goyodiaz'
    dependencies = []
    files = ['45203']
    hgrepos = []
    issue_num = 27939
    keywords = ['patch']
    message_count = 3.0
    messages = ['274223', '279307', '279732']
    nosy_count = 3.0
    nosy_names = ['python-dev', 'serhiy.storchaka', 'goyodiaz']
    pr_nums = ['552']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue27939'
    versions = ['Python 3.5', 'Python 3.6', 'Python 3.7']

    @goyodiaz
    Copy link
    Mannequin Author

    goyodiaz mannequin commented Sep 2, 2016

    Calling mainloop after setting the value of a ttk.LabeledScale raises an error. The same happens if the value is set after entering the mainloop.

    Does not affect python 3.4.3. Does not affect ttk.Scale. No error is raised if you do not call mainloop.

    import tkinter as tk
    import tkinter.ttk as ttk
    root = tk.Tk()
    w = ttk.LabeledScale(root)
    w.pack()
    w.scale.set(1)
    root.mainloop()
    Traceback (most recent call last):
      File "d:\users\u938001\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py", line 1550, in __call__
        return self.func(*args)
      File "d:\users\u938001\AppData\Local\Programs\Python\Python35-32\lib\tkinter\ttk.py", line 1540, in _adjust
        newval = self._variable.get()
      File "d:\users\u938001\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py", line 355, in get
        return self._tk.getint(self._tk.globalgetvar(self._name))
    TypeError: getint() argument must be str, not float
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "itcomp.py", line 8, in <module>
        root.mainloop()
      File "d:\users\u938001\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py", line 1131, in mainloop
        self.tk.mainloop(n)
      File "d:\users\u938001\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py", line 1554, in __call__
        self.widget._report_exception()
    AttributeError: 'IntVar' object has no attribute '_report_exception'

    @goyodiaz goyodiaz mannequin added type-crash A hard crash of the interpreter, possibly with a core dump topic-tkinter labels Sep 2, 2016
    @terryjreedy terryjreedy added type-bug An unexpected behavior, bug, or error and removed type-crash A hard crash of the interpreter, possibly with a core dump labels Sep 3, 2016
    @serhiy-storchaka
    Copy link
    Member

    This is caused by replacing int() by self._tk.getint() in IntVar.get() (bpo-23880). But the failure can be reproduced even in 3.4 if set tk.wantobjects = 0 before creating root widget.

    One way is making getint() accepting floats. This fizes original example, but doesn't solve the issue for tk.wantobjects = 0.

    Other way is making IntVar.get() falling back to integer part of getdouble(). This fixes the example in both modes. Proposed patch goes this way.

    @serhiy-storchaka serhiy-storchaka added the 3.7 (EOL) end of life label Oct 24, 2016
    @serhiy-storchaka serhiy-storchaka self-assigned this Oct 24, 2016
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Oct 30, 2016

    New changeset 394b2b4da150 by Serhiy Storchaka in branch '3.5':
    Issue bpo-27939: Fixed bugs in tkinter.ttk.LabeledScale and tkinter.Scale caused
    https://hg.python.org/cpython/rev/394b2b4da150

    New changeset 91884d043fdc by Serhiy Storchaka in branch '3.6':
    Issue bpo-27939: Fixed bugs in tkinter.ttk.LabeledScale and tkinter.Scale caused
    https://hg.python.org/cpython/rev/91884d043fdc

    New changeset 9e3931aa1ff0 by Serhiy Storchaka in branch 'default':
    Issue bpo-27939: Fixed bugs in tkinter.ttk.LabeledScale and tkinter.Scale caused
    https://hg.python.org/cpython/rev/9e3931aa1ff0

    @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 topic-tkinter type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants