[Tkinter-discuss] Syntactic problems
klappnase at web.de
Fri Dec 2 19:24:19 CET 2011
Thus spoketh Kevin Walzer <kw at codebykevin.com>
unto us on Fri, 02 Dec 2011 10:45:04 -0500:
> > Â Â Â .t tag configure f[incr count] -font [list $family 10]
> > Â
> > The function *list* of *Tcl* seems to be mainly dedicated to solve
> > this odd problem with the dereferencing of multiword contents of
> > variables (*family* in this case, which holds the name of the font).
> > But apparently this does not work when *Tcl/Tk* are finally moved by
> > *Tkinter* during the execution of the script or at least I have been
> > unable to find a way to make it work in due form.
> I'm not quite clear on what problem you are experiencing here, as there
> are no code snippets or Python errors outlined.
> Are you just trying to understand the underlying Tcl idioms?
Maybe Francisco meant the following:
>>> l = Label(text='foo')
>>> l.config(font='Helvetica 12')
this works, but:
>>> l.config(font='Bitstream Vera Sans 12')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1205, in configure
return self._configure('configure', cnf, kw)
File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1196, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: expected integer but got "Vera"
I think the Tkinter equivalent to tcl's list command in this context is
to simply pass a sequence instead of a string to the font option:
>>> l.config(font=('Bitstream Vera Sans', '12'))
just like one would do in other cases where Tk expects a list, as e.g.
.-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.
It would seem that evil retreats when forcibly confronted.
-- Yarnek of Excalbia, "The Savage Curtain", stardate
More information about the Tkinter-discuss