Kaydet (Commit) 70c3dda2 authored tarafından Martin v. Löwis's avatar Martin v. Löwis

Convert booleans to integers in IntVar.set. Fixes #671741.

Return booleans from _tkinter.getboolean.
Convert booleans to Tcl booleans in AsObj.
üst d7ceb222
......@@ -234,6 +234,12 @@ class IntVar(Variable):
MASTER can be given as master widget."""
Variable.__init__(self, master)
def set(self, value):
"""Set the variable to value, converting booleans to integers."""
if isinstance(value, bool):
value = int(value)
return Variable.set(self, value)
def get(self):
"""Return the value of the variable as an integer."""
return getint(self._tk.globalgetvar(self._name))
......
......@@ -868,6 +868,8 @@ AsObj(PyObject *value)
if (PyString_Check(value))
return Tcl_NewStringObj(PyString_AS_STRING(value),
PyString_GET_SIZE(value));
else if (PyBool_Check(value))
return Tcl_NewBooleanObj(PyObject_IsTrue(value));
else if (PyInt_Check(value))
return Tcl_NewLongObj(PyInt_AS_LONG(value));
else if (PyFloat_Check(value))
......@@ -1739,7 +1741,7 @@ Tkapp_GetBoolean(PyObject *self, PyObject *args)
return NULL;
if (Tcl_GetBoolean(Tkapp_Interp(self), s, &v) == TCL_ERROR)
return Tkinter_Error(self);
return Py_BuildValue("i", v);
return PyBool_FromLong(v);
}
static PyObject *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment