documentation for tk.call interface
kw at codebykevin.com
Tue Oct 16 19:59:34 CEST 2007
dbr517 at gmail.com wrote:
> I'm using Python + Tkinter for a small gui . . . there are LOTS of
> places inside Tkinter with code like this:
> self.tk.call('tkwait', 'variable', name)
> (this particular one is from the IntVar class).
> I've searched the Tkinter docs with no success; can someone point me
> at the documentation for tk.call?
I'm not sure where the documentation is, but tk.call is a raw Tcl
command being invoked from Python without being wrapped by Python
classes/methods. For instance:
self.tk.call('package', 'require', 'tile')
is equivalent to this call in a Tcl script:
package require tile
Generally I use tk.call if I have to get "close to the metal" in dealing
with Tk. Tkinter does a good job of abstracting this, but, as you no
doubt know, Tkinter.py itself is full of 'tk.call' code, i.e.:
def wait_visibility(self, window=None):
"""Wait until the visibility of a WIDGET changes
(e.g. it appears).
If no parameter is given self is used."""
if window is None:
window = self
self.tk.call('tkwait', 'visibility', window._w)
def setvar(self, name='PY_VAR', value='1'):
"""Set Tcl variable NAME to VALUE."""
def getvar(self, name='PY_VAR'):
"""Return value of Tcl variable NAME."""
and so on. There's simply no other way to get at the guts of Tk without
using tk.call at some level.
Code by Kevin
More information about the Python-list