[Python-bugs-list] Re: Tkinter wm_colormapwindows doesn't work w/o breaking Tkinter encapsulation (PR#107)
aa8vb@yahoo.com
aa8vb@yahoo.com
Tue, 19 Oct 1999 08:04:54 -0400 (EDT)
Guido van Rossum:
|Randall Hopper:
|> In Tcl/Tk you can say:
|>
|> wm colormapwindows . {.frame.label .frame}
|>
|> In Tkinter, one would think you could use:
|>
|>
|> but this results in an error:
|>
|> TclError: wrong # arguments: must be "wm colormapwindows window
|> ?windowList?"
|>
|> this is what is sent to Tk:
|> ('wm', 'colormapwindows', '.269680944',
|> <Tkinter.Label instance at 101302e0>,
|> <Tkinter.Frame instance at 10130280>)
|>
|> As a workaround, the following works (or at least Tk doesn't complain
|> about it) but is obviously a hack:
|>
|> main.tk.call( "wm", "colormapwindows", main._w,
|> '%s %s' % ( canvas._w, frame._w ) )
|
|The Python function doesn't require you to put the windows in a list.
|Instead, it takes any number of windows as separate arguments.
|This should work:
|
| main.wm_colormapwindows(label, frame)
On Python 1.52, this yields:
------------------------------------------------------------------------------
Traceback (innermost last):
File "./3-tk_win.py", line 106, in ?
main.wm_colormapwindows( label, frame )
File "/home/rhh/software/IRIX-o32/python-1.5.2/lib/python1.5/lib-tk/Tkinter.py", line 785, in wm_colormapwindows
return map(self._nametowidget, self.tk.call(args))
TclError: wrong # arguments: must be "wm colormapwindows window ?windowList?"
------------------------------------------------------------------------------
I inserted a print of args into wm_colormapwindows:
------------------------------------------------------------------------------
def wm_colormapwindows(self, *wlist):
args = ('wm', 'colormapwindows', self._w) + _flatten(wlist)
-> print args
return map(self._nametowidget, self.tk.call(args))
------------------------------------------------------------------------------
and this is what is being passed to self.tk.call:
------------------------------------------------------------------------------
('wm', 'colormapwindows', '.', <Tkinter.Label instance at 10120d58>, <Tkinter.Frame instance at 10120b58>)
------------------------------------------------------------------------------
From first glance, it appears there may be two problems:
1) the Tkinter objects aren't being translated to Tk widget names
(label._w, frame._w), and
2) The window list isn't being passed to Tk as a Tk list
(i.e. one arg to tk.call)
Together, I believe this is why the following raw Tk call doesn't complain:
------------------------------------------------------------------------------
|> main.tk.call( "wm", "colormapwindows", main._w,
|> '%s %s' % ( label._w, frame._w ) )
------------------------------------------------------------------------------
Thanks,
Randall