Tkinter text widget

Fredrik Lundh fredrik at pythonware.com
Sat Feb 17 04:52:40 EST 2001


"Harvest T. Moon" wrote:
> how do i change the text color for specific lines in a text widget, so i can
> have different lines with different colored text? (or at least some words
> different colored/styled i.e. bold etc.)

use tags:

    text.tag_config("highlight", foreground="red")
    text.insert(INSERT, "red text", "highlight") # insert coloured text
    text.tag_add("highlight", 5.0, 6.0) # highlight line 5

also see:

http://www.pythonware.com/library/tkinter/introduction/text.htm
=> "concepts"

Cheers /F

<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->





More information about the Python-list mailing list