in reply to Coloring text using TK?
#!/usr/bin/perl -w use Tk; my $top = MainWindow->new; my $t = $top->Text(); $t->tagConfigure("boring", -foreground => "blue"); $t->tagConfigure("special", -foreground => "red"); $t->insert("end", "If you want to be immune from silly letters, don't +carry your momomark in your hat.\n"); $t->insert("end", "bij bij\n", "special"); $t->insert("end", "Zoem your Zoem\n", "boring"); my $word = "your"; my $word_len = length $word; my $next = "1.0"; while (my $from = $t->search(-regexp, "\\b$word\\b", $next, "end")) { $next = "$from + $word_len chars"; $t->tagAdd("special", $from, $next); } $t->pack; MainLoop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Coloring text using TK?
by Elijah (Hermit) on Dec 01, 2003 at 21:46 UTC | |
by thospel (Hermit) on Dec 01, 2003 at 22:53 UTC | |
by Elijah (Hermit) on Dec 02, 2003 at 05:01 UTC | |
by Elijah (Hermit) on Dec 02, 2003 at 20:32 UTC |