Message313213
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! |
|
Date |
User |
Action |
Args |
2018-03-04 15:26:53 | cheryl.sabella | set | recipients:
+ cheryl.sabella, terry.reedy, serhiy.storchaka |
2018-03-04 15:26:53 | cheryl.sabella | set | messageid: <1520177213.57.0.467229070634.issue32839@psf.upfronthosting.co.za> |
2018-03-04 15:26:53 | cheryl.sabella | link | issue32839 messages |
2018-03-04 15:26:53 | cheryl.sabella | create | |
|