Cheryl Sabella <[email protected]> added the comment:
A few questions about returning the Python function name (specifically, how to
derive it). This doesn't address the open issue with what to do about a Tcl
command not tied to a Python function.
1. Serhiy wrote "and the API for restoring the original Python callable is
private." What is that API?
2. In the _register method, the Tcl command name is the callback ID + the
function name:
f = CallWrapper(callback, None, self._root).__call__
cbname = repr(id(f))
try:
callback = callback.__func__
except AttributeError:
pass
try:
cbname = cbname + callback.__name__
except AttributeError:
pass
So, with the values returned from tk.call('after', 'info', id) as (script,
type), the Python function should be the same as script.lstrip('0123456789').
I'm not sure if that would be the best way to get the name back.
3. In tkinter, there is a list created/added to during _register:
self._tclCommands.append(cbname)
where cbname is the Tcl command name (as defined by the code in q2 above).
Would it be possible to change _tclCommands to a dict mapping Tcl command name
to Python function name? _tclCommands already has some logic around it,
including .remove functions, so I think a dictionary would be more efficient
for the exisitng purposes. Since it's semi-private, is there a fear with
backward compatibility if it changes from a list to a dict? Is it better to
add a new dict variable?
Thanks!
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue32839>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com