Skip to content

Commit ac68d83

Browse files
[3.12] gh-120211: Fix tkinter.ttk with Tcl/Tk 9.0 (GH-120213) (GH-120216)
* 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 ec139c8 commit ac68d83

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
@@ -683,7 +683,10 @@ def current(self, newindex=None):
683683
returns the index of the current value in the list of values
684684
or -1 if the current value does not appear in the list."""
685685
if newindex is None:
686-
return self.tk.getint(self.tk.call(self._w, "current"))
686+
res = self.tk.call(self._w, "current")
687+
if res == '':
688+
return -1
689+
return self.tk.getint(res)
687690
return self.tk.call(self._w, "current", newindex)
688691

689692

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

15171520
# update the label as scale or variable changes
1518-
self.__tracecb = self._variable.trace_variable('w', self._adjust)
1521+
self.__tracecb = self._variable.trace_add('write', self._adjust)
15191522
self.bind('<Configure>', self._adjust)
15201523
self.bind('<Map>', self._adjust)
15211524

15221525

15231526
def destroy(self):
15241527
"""Destroy this widget and possibly its associated variable."""
15251528
try:
1526-
self._variable.trace_vdelete('w', self.__tracecb)
1529+
self._variable.trace_remove('write', self.__tracecb)
15271530
except AttributeError:
15281531
pass
15291532
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)