https://github.com/python/cpython/commit/8368b67d1b5db48807010936d9550e762fc8630d
commit: 8368b67d1b5db48807010936d9550e762fc8630d
branch: 3.13
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: serhiy-storchaka <storch...@gmail.com>
date: 2024-06-07T15:00:30Z
summary:

[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 d68a22e7a68ae09f7db61d5a1a3bd9c0360cf3ee)

Co-authored-by: Serhiy Storchaka <storch...@gmail.com>

files:
A Misc/NEWS.d/next/Library/2024-06-07-13-21-11.gh-issue-120211.Rws_gf.rst
M Lib/tkinter/ttk.py

diff --git a/Lib/tkinter/ttk.py b/Lib/tkinter/ttk.py
index 5ca938a670831a..073b3ae20797c3 100644
--- a/Lib/tkinter/ttk.py
+++ b/Lib/tkinter/ttk.py
@@ -690,7 +690,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)
 
 
@@ -1522,7 +1525,7 @@ 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)
 
@@ -1530,7 +1533,7 @@ def __init__(self, master=None, variable=None, from_=0, 
to=10, **kw):
     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:
diff --git 
a/Misc/NEWS.d/next/Library/2024-06-07-13-21-11.gh-issue-120211.Rws_gf.rst 
b/Misc/NEWS.d/next/Library/2024-06-07-13-21-11.gh-issue-120211.Rws_gf.rst
new file mode 100644
index 00000000000000..0106f2d93318b4
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-06-07-13-21-11.gh-issue-120211.Rws_gf.rst
@@ -0,0 +1 @@
+Fix :mod:`tkinter.ttk` with Tcl/Tk 9.0.

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to