From: S-Y. Chen on

I am trying to make my text widget highlighting certain keywords. I
search the newsgroup archive and did not find anything easy.

Is there a simple way to do this ?


Regards
S-Y. Chen
From: Miko on
Hi
look at Ctext....

Miko
"S-Y. Chen" <shenyeh_chen(a)hotmail.com> a �crit dans le message de news:
32399f2a-c9e1-43a9-b1b3-238d47931692(a)e37g2000yqn.googlegroups.com...
>
> I am trying to make my text widget highlighting certain keywords. I
> search the newsgroup archive and did not find anything easy.
>
> Is there a simple way to do this ?
>
>
> Regards
> S-Y. Chen


From: Bryan Oakley on
On Jan 7, 11:04 am, "S-Y. Chen" <shenyeh_c...(a)hotmail.com> wrote:
> I am trying to make my text widget highlighting certain keywords. I
> search the newsgroup archive and did not find anything easy.
>
> Is there a simple way to do this ?
>
> Regards
> S-Y. Chen

One simple solution that works surprisingly well is to put a binding
on KeyRelease. Simply search forward and backwards for the start and
end of the current word. Look up the word in an array or dict for the
color, and apply a tag with that color to the word.

It may sound like overkill to do it on every keypress, but it's just a
few lines of code that executes in just a few milliseconds.
From: slebetman on
On Jan 8, 1:57 am, Bryan Oakley <oak...(a)bardo.clearlight.com> wrote:
> On Jan 7, 11:04 am, "S-Y. Chen" <shenyeh_c...(a)hotmail.com> wrote:
>
> > I am trying to make my text widget highlighting certain keywords. I
> > search the newsgroup archive and did not find anything easy.
>
> > Is there a simple way to do this ?
>
> > Regards
> > S-Y. Chen
>
> One simple solution that works surprisingly well is to put a binding
> on KeyRelease. Simply search forward and backwards for the start and
> end of the current word. Look up the word in an array or dict for the
> color, and apply a tag with that color to the word.
>
> It may sound like overkill to do it on every keypress, but it's just a
> few lines of code that executes in just a few milliseconds.

If it's just keyword highlighting and not syntax highlighting in
general then you can simply re-parse the current line and re-hilight
the line. It's fast enough. It's what I do for my own code editor.
From: Arjen Markus on
On 7 jan, 18:43, "Miko" <michel.salvagn...(a)free.fr> wrote:
> Hi
> look at Ctext....
>
> Miko
> "S-Y. Chen" <shenyeh_c...(a)hotmail.com> a écrit dans le message de news:
> 32399f2a-c9e1-43a9-b1b3-238d47931...(a)e37g2000yqn.googlegroups.com...
>
>
>
>
>
> > I am trying to make my text widget highlighting certain keywords. I
> > search the newsgroup archive and did not find anything easy.
>
> > Is there a simple way to do this ?
>
> > Regards
> > S-Y. Chen- Tekst uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -

Yes, ctext in the Tklib library is the easiest way to accomplish this.

Regards,

Arjen