-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Tkinter mainloop raises when setting the value of ttk.LabeledScale #72126
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
Comments
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' |
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. |
New changeset 394b2b4da150 by Serhiy Storchaka in branch '3.5': New changeset 91884d043fdc by Serhiy Storchaka in branch '3.6': New changeset 9e3931aa1ff0 by Serhiy Storchaka in branch 'default': |
Misc/NEWS
so that it is managed by towncrier #552Note: 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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: