mirror of https://github.com/python/cpython
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.
This commit is contained in:
parent
6646a9da26
commit
d68a22e7a6
|
@ -690,7 +690,10 @@ class Combobox(Entry):
|
||||||
returns the index of the current value in the list of values
|
returns the index of the current value in the list of values
|
||||||
or -1 if the current value does not appear in the list."""
|
or -1 if the current value does not appear in the list."""
|
||||||
if newindex is None:
|
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)
|
return self.tk.call(self._w, "current", newindex)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1522,7 +1525,7 @@ class LabeledScale(Frame):
|
||||||
self.label.place(anchor='n' if label_side == 'top' else 's')
|
self.label.place(anchor='n' if label_side == 'top' else 's')
|
||||||
|
|
||||||
# update the label as scale or variable changes
|
# 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('<Configure>', self._adjust)
|
||||||
self.bind('<Map>', self._adjust)
|
self.bind('<Map>', self._adjust)
|
||||||
|
|
||||||
|
@ -1530,7 +1533,7 @@ class LabeledScale(Frame):
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
"""Destroy this widget and possibly its associated variable."""
|
"""Destroy this widget and possibly its associated variable."""
|
||||||
try:
|
try:
|
||||||
self._variable.trace_vdelete('w', self.__tracecb)
|
self._variable.trace_remove('write', self.__tracecb)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix :mod:`tkinter.ttk` with Tcl/Tk 9.0.
|
Loading…
Reference in New Issue