Skip to content

[3.12] gh-120211: Fix tkinter.ttk with Tcl/Tk 9.0 (GH-120213) #120216

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 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-120211: Fix tkinter.ttk with Tcl/Tk 9.0 (GH-120213)
* Use new methods for tracing Tcl variable.
* Fix Combobox.current() for empty combobox.
(cherry picked from commit d68a22e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
  • Loading branch information
serhiy-storchaka authored and miss-islington committed Jun 7, 2024
commit be198546cfa8cc9c75fa2f926f7f3e018e723dd4
9 changes: 6 additions & 3 deletions Lib/tkinter/ttk.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,10 @@ def current(self, newindex=None):
returns the index of the current value in the list of values
or -1 if the current value does not appear in the list."""
if newindex is None:
return self.tk.getint(self.tk.call(self._w, "current"))
res = self.tk.call(self._w, "current")
if res == '':
return -1
return self.tk.getint(res)
return self.tk.call(self._w, "current", newindex)


Expand Down Expand Up @@ -1515,15 +1518,15 @@ def __init__(self, master=None, variable=None, from_=0, to=10, **kw):
self.label.place(anchor='n' if label_side == 'top' else 's')

# update the label as scale or variable changes
self.__tracecb = self._variable.trace_variable('w', self._adjust)
self.__tracecb = self._variable.trace_add('write', self._adjust)
self.bind('<Configure>', self._adjust)
self.bind('<Map>', self._adjust)


def destroy(self):
"""Destroy this widget and possibly its associated variable."""
try:
self._variable.trace_vdelete('w', self.__tracecb)
self._variable.trace_remove('write', self.__tracecb)
except AttributeError:
pass
else:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix :mod:`tkinter.ttk` with Tcl/Tk 9.0.
Loading