2011-12-02 12:09:32 GMT
I am exploring the possibilities of using *Tkinter* for a serious application mainly devoted to the handling of pure text.
As en exercise I have tried to rewrite in *Python* an interesting example that is unusually included in the manual page of *Tk* for the *font* component (*Tcl8.5.7/Tk8.5.7 Documentation > TkCmd > font > example*); this code works fine under *tclsh* and *wish*. What is does is getting a list of the font names available in the machine in which it is running and displaying nicely each of its items with a sample of the corresponding font.
I have performed most of my purpose and my *Python* script works. Along the way have learned a lot about *Tkinter/Tk/Tcl*, which was also a desired goal of the exercise. But the script does not work completely well, as I have also hit against an obstacle that I do not know how to overcome and seems to be rather deep. It is the following:
Some of the names of the font families returned by the operating system (be it Windows or Linux) are composed of two or more words (like *Times New Roman CE*). Now these multiword arguments are not easily accepted by *Tcl/Tk*, especially if they are referenced by some variable, so that for instance tags cannot be reconfigured this way in order to apply such fonts; or the size of sentences using them cannot be measured, two operations that are essential for the procedure.
I have learned that this is a real and inherent difficulty with *Tcl* (Harrison and McLennan, *Effective Tcl/Tk programming*: 34, 66); this is why the original code uses such a strange syntax like
.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.
Which does not mean much, as I am not a programmer or, at most, I am a very unseasoned one. Can somebody who has had the same problem and solved it succesfully from *Tkinter* offer me (and perhaps us) his insight and describe the essentials of how to do it?
Many thanks in advance!
_______________________________________________ Tkinter-discuss mailing list Tkinter-discuss <at> python.org http://mail.python.org/mailman/listinfo/tkinter-discuss