Commit 88b63b8d authored by Guido van Rossum's avatar Guido van Rossum

Allow binding a Tcl command (given as a string) as well as a Python

function.
parent e5836d98
...@@ -450,7 +450,9 @@ class Misc: ...@@ -450,7 +450,9 @@ class Misc:
else: else:
self.tk.call('bindtags', self._w, tagList) self.tk.call('bindtags', self._w, tagList)
def _bind(self, what, sequence, func, add, needcleanup=1): def _bind(self, what, sequence, func, add, needcleanup=1):
if func: if type(func) is StringType:
self.tk.call(what + (sequence, func))
elif func:
funcid = self._register(func, self._substitute, funcid = self._register(func, self._substitute,
needcleanup) needcleanup)
cmd = ('%sif {"[%s %s]" == "break"} break\n' cmd = ('%sif {"[%s %s]" == "break"} break\n'
...@@ -460,8 +462,6 @@ class Misc: ...@@ -460,8 +462,6 @@ class Misc:
_string.join(self._subst_format))) _string.join(self._subst_format)))
self.tk.call(what + (sequence, cmd)) self.tk.call(what + (sequence, cmd))
return funcid return funcid
elif func == '':
self.tk.call(what + (sequence, func))
else: else:
return self.tk.call(what + (sequence,)) return self.tk.call(what + (sequence,))
def bind(self, sequence=None, func=None, add=None): def bind(self, sequence=None, func=None, add=None):
......
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