Writing a read only attribute

  • Thread starter Fabrizio Pollastri
  • Start date
F

Fabrizio Pollastri

My code is the following:

from Tkinter import *

def tk_dummy_call(*args):
return

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.
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

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
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top