Many thanks to you both, Kevin and Michael for your quick and sensible responses. My problems are more in the line suggested by Michael, although his hint has not solved them, at least as I have tried to implement it.<br><br>
In order for you to have all the information together, I transcribe the original Tcl code and my *porting* of it to *tkinter*. I commented it for my own use, in the process of conjecturing and confirming what the original code was intended to perform.<br>
<br>If you run the original code with *tclsh* or *wish* and then my code with *Idle*, you will see very clearly where the problem lies.<br><br>Kind regards<br><br>Francisco<br><br># original Tcl code<br># offered as example in the *font manual page* of TkDocs.<br>
# Runs without problems with *tclsh* and *wish*<br><br># pack [text .t -wrap none] -fill both -expand 1<br># set count 0<br># set tabwidth 0<br># foreach family [lsort -dictionary [font families]] {<br>#    .t tag configure f[incr count] -font [list $family 10]<br>
#    .t insert end ${family}:\t {} \<br>#            &quot;This is a simple sampler\n&quot; f$count<br>#    set w [font measure [.t cget -font] ${family}:]<br>#    if {$w+5 &gt; $tabwidth} {<br>#        set tabwidth [expr {$w+5}]<br>
#        .t configure -tabs $tabwidth<br>#    }<br># }<br><br><br>from tkinter import *<br>from tkinter import font<br><br><br># creation of the main window<br>master = Tk()<br><br># creation of a text widget<br>tw = Text( master )<br>
tw.config( wrap = NONE )<br>tw.pack( fill = BOTH, expand = 1 )<br><br>tw.insert( END, &quot;Display of available fonts:\n\n&quot; )<br><br>count = 0<br>tabwidth = 0<br><br># identification of the font being used<br>f1 = tw.cget( &#39;font&#39; )<br>
<br># a measurement function used later<br># is a method of class *tkinter.font.Font*,<br># so that it is good to have the required instance of it<br>fo = font.Font( font = ( f1, 10 ) )<br><br># let us get the ordered list of all<br>
# available font families<br>sampler = sorted( list( font.families() ) )<br><br># handling and display of the elements<br>for f in sampler :<br>    # the counter is updated<br>    count += 1<br>    # display of the provided font name plus<br>
    # a separator and a tabulator<br>    tw.insert( END, f + &quot;:\t&quot; )<br>    # creation of an individual name for the tag<br>    # that will be applied to the sample for this item<br>    ftag = f + str( count )<br>
<br>    # my (vain) efforts to solve the multiword problem<br>    if &#39; &#39; in f :<br>#        fm = &quot;(&#39;&quot; + f + &quot;&#39;, &#39;10&#39;)&quot;   # as for Michael&#39;s hint<br>        fm = &#39;[list &#39; + f + &#39;]&#39;<br>
#        fm = f.replace( &#39; &#39;, &#39;_&#39; )<br>#        fm = f.replace( &#39; &#39;, &#39;&#39; )<br>        tw.tag_config( ftag, font = ( fm, 10 ) )<br>#        tw.tag_config( ftag, font = fm )<br>    else :<br>        # single word names work as expected<br>
        tw.tag_config( ftag, font = ( f, 10 ) )<br>    # and the sample text:<br>    tw.insert( END, &quot;This is a simple sampler\n&quot;, ftag )<br>    <br>    # nice columnar disposition by<br>    # a clever configuration of the tabulator<br>
    w = fo.measure( f + &#39;:&#39; )<br>    if ( w + 5 ) &gt; tabwidth :<br>        tabwidth = w + 5<br>        # this equalizes all the lines as required<br>        tw.config( tabs = tabwidth )<br><br>if __name__ == &#39;__main__&#39; :<br>
    master.mainloop()<br><br><br><br>