Skip to content

Commit 8368b67

Browse files
[3.13] gh-120211: Fix tkinter.ttk with Tcl/Tk 9.0 (GH-120213) (GH-120215)
* 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>
1 parent a2003bd commit 8368b67

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Lib/tkinter/ttk.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,10 @@ def current(self, newindex=None):
690690
returns the index of the current value in the list of values
691691
or -1 if the current value does not appear in the list."""
692692
if newindex is None:
693-
return self.tk.getint(self.tk.call(self._w, "current"))
693+
res = self.tk.call(self._w, "current")
694+
if res == '':
695+
return -1
696+
return self.tk.getint(res)
694697
return self.tk.call(self._w, "current", newindex)
695698

696699

@@ -1522,15 +1525,15 @@ def __init__(self, master=None, variable=None, from_=0, to=10, **kw):
15221525
self.label.place(anchor='n' if label_side == 'top' else 's')
15231526

15241527
# update the label as scale or variable changes
1525-
self.__tracecb = self._variable.trace_variable('w', self._adjust)
1528+
self.__tracecb = self._variable.trace_add('write', self._adjust)
15261529
self.bind('<Configure>', self._adjust)
15271530
self.bind('<Map>', self._adjust)
15281531

15291532

15301533
def destroy(self):
15311534
"""Destroy this widget and possibly its associated variable."""
15321535
try:
1533-
self._variable.trace_vdelete('w', self.__tracecb)
1536+
self._variable.trace_remove('write', self.__tracecb)
15341537
except AttributeError:
15351538
pass
15361539
else:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix :mod:`tkinter.ttk` with Tcl/Tk 9.0.

0 commit comments

Comments
 (0)