[issue27405] Ability to trace Tcl commands executed by Tkinter

Terry J. Reedy report at bugs.python.org
Fri Jul 1 17:20:01 EDT 2016


Terry J. Reedy added the comment:

In "debug = False+1', I presume the '+1' is just temporary.

The debug property and the clinic file refer to _tkinter.tkapp.get/settrace, which do not exist.  Did you just forget to include that part?  Or does 'preliminary' mean 'do not test yet'?

>>> import tkinter
>>> tkinter.debug
1
>>> import idlelib.idle
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "F:\Python\dev\36\lib\idlelib\idle.py", line 11, in <module>
    idlelib.pyshell.main()
  File "F:\Python\dev\36\lib\idlelib\pyshell.py", line 1553, in main
    root = Tk(className="Idle")
  File "F:\Python\dev\36\lib\tkinter\__init__.py", line 2018, in __init__
    self.debug = debug
  File "F:\Python\dev\36\lib\tkinter\__init__.py", line 2110, in debug
    self.tk.settrace(trace)
AttributeError: '_tkinter.tkapp' object has no attribute 'settrace'

At least the error shows that the code works as far as written ;-).

I now understand 'larger customization ...' to mean supplying a trace function other than the default, to do something with 'cmd' other than just print it.  For instance, one could record tcl commands in a file and later count the tcl function calls, much like python's trace does.  To do that, I believe you could just replace 'def trace ... with

if iscallable(value):
    trace = value
else:
    def trace ...

+1 on adding this.  The default trace would be useful for simple interaction, but less so for what I tried to do above, which is to trace a complete IDLE session.

----------
assignee:  -> serhiy.storchaka
stage:  -> test needed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27405>
_______________________________________


More information about the Python-bugs-list mailing list