Dynamic text color

Cousin Stanley cousinstanley at gmail.com
Sat Jan 2 03:01:04 CET 2010


> John Posner wrote  ....
> ....
> I've posted a complete solution ....
>   
>   http://cl1p.net/jjp_dynamic_text_color/.

  John .... 

    Thanks for posting your solution to Dave McCormick's query
    about colorizing text .... 

    I was not familiar with the re.finditer method
    for searching strings or with using tags in 
    Tkinter Text widgets to change text attributes .... 

    Instead of binding the Text widget to <KeyRelease> events
    to call the colorizer on each key-stroke, I used a button
    callback ....  

       http://cl1p.net/cs_static_text_color

    This provides a static one-shot colorization after all
    of the text is entered and should save a few cpu cycles 
    although it's not as nifty as the dynamic process .... 

    I used a dictionary instead of a list for position data
    and also added a  { term : color }  dictionary so that 
    words other than color names can be hi-lighted ....


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona




More information about the Python-list mailing list