[Tutor] Color text in Text widget

sunny sunny sunny.tired at gmail.com
Tue Aug 2 15:40:31 CEST 2005


Thanks.
Its works very well.
Santosh.

On 8/1/05, Jorge Louis de Castro <jobauk at hotmail.com> wrote:
> I found a way to do it but I'm not sure it is the cleanest. Maybe someone
> else on this list can offer a better solution.
> 
> I use the text's configuration to define tags that I apply to sections of
> the text. For example:
> 
> txtBox = Text(self, width=80, height=20)
> # configuration for red
> txtBox.tag_config("r", foreground="red")
> # configuration for blue
> txtBox.tag_config("b", foreground="blue")
> 
> txtBox.insert(END,"I am red ", "r")
> txtBox.insert(END,"and I am blue\n", "b")
> 
> Hope that helps
> jorge
> 
> >From: sunny sunny <sunny.tired at gmail.com>
> >To: tutor at python.org
> >Subject: [Tutor] Color text in Text widget
> >Date: Mon, 1 Aug 2005 15:35:52 -0400
> >
> >Hi all,
> >
> >How do I add color to the text in the Text widget? I tried using the
> >ASCII sequence but it didnt work.
> >
> >For example, I want to add:
> >  This is <Red> red <Red>, but this is <Blue> blue <Blue>
> >
> >Thanks.
> >Santosh.
> >_______________________________________________
> >Tutor maillist  -  Tutor at python.org
> >http://mail.python.org/mailman/listinfo/tutor
> 
> 
>


More information about the Tutor mailing list