This is a follow up question from this one where it is suggested to implement the bgerror
to actually get a response to what went wrong in the background. However I'm a bit confused, as I understand the documentation it should be sufficient to define a proc
named bgerror
that will be called by the interpreter, doesn't it ?
My attempt below shows how I try to implement it, with no effect at all.
import tkinter as tk
tcl = tk.Tk()
####work around for puts in python
def puts(inp):
print(inp)
cmd = tcl.register(puts)
tcl.eval(
'proc puts {args} {' +
f'{cmd} [join $args " "]' +
'}')
tcl.call('puts', 'test') #test puts
#attempt to implement bgerror
tcl.eval('''
proc bgerror {message} {
set timestamp [clock format [clock seconds]]
puts "$timestamp: bgerror in $::argv '$message'"
}''')
#setup a failing proc
tcl.eval('''
after 500 {error "this is an error"}
''')
tcl.mainloop()
In addition, it would be nice to know if this is the right approach at all, since the documentation suggests for newer applications to use interp bgerror
. But again I'm confused, cause there seems to be no indicator where I could find the path
for these calls or are they for child interpreter exclusively ?