Thread: Highlight words

    #1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Somewhere over the Rainbow
    Posts
    128
    Rep Power
    12

    Highlight words


    Hi, I would like to know how can I Highlight words with specific colors in my Tkinter code? I guess I can use the tokenize module, Im making something like the below code. is that correct? or what can I do to Highlight words?

    Thanks a lot.

    Code:
    import tokenize
    import keyword
    
    KEYWORD="Keyword"
    
    TOKEN_START={tokenize.Word:"<font color=BLUE>",
                      tokenize.Word1:"<font color=RED>",
                      tokenizeWord2:"<font color=GREEN>",
                      Word3:"<font color=ORANGE>",
    
    TOKEN_END={tokenize.Word::"</font>",
                    tokenize.Word1:"</font>",
                    tokenize.Word2:"</font>",
                    Word3:"</font>",
                    }
    Last edited by Gerardoj; December 1st, 2003 at 01:10 PM.
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,625
    Rep Power
    4247
    Jurgen Hermann wrote a python colorizer using the tokenize module. His code outputs HTML file, but you could modify it to use tkinter.
    http://twistedmatrix.com/users/jh.tw...nMoinColorizer
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo

IMN logo majestic logo threadwatch logo seochat tools logo