Writing a read only attribute

"Martin v. Löwis" martin at v.loewis.de
Fri Jul 6 04:51:07 EDT 2007


> root = Tk()
> 
> # save call address
> original_tk_call = root.tk.call
> 
> # disable tcl command execution (this is the read-only attribute)
> root.tk.call = tk_dummy_call
> 
> ... some code ...
> 
> # restore tcl command execution
> root.tk.call = original_tk_call
> 
> 
> My goal is to make instances of Tkinter widgets without the effects of
> commands directed to the tcl interpreter but preserving all effects at
> python level.

You can try to put in a fake Tk object into root.tk, as root.tk is not
read-only. However, I would expect you run into other problems trying
to do so.

To change root.tk.call, you need to modify the implementation of the
_tkinter module.

Regards,
Martin




More information about the Python-list mailing list