> to find things in a text widget, use the "search" method:> > pos = 
> text.search(string, start)> > where "string" is the string you want to search 
> for, and start is the > starting position (e.g. 1.0 or INSERT).> > to search 
> for things that match "@word", where "word" is an arbitrary > string of 
> letters or digits, you can use a regular expression, e.g.> > pos = 
> text.search("@\w+", 1.0, regexp=True)> > search only returns where the match 
> begins; to find the end of "@word", > you can search from the given position 
> to the first thing that isn't a > word character:> > end = text.search("\W", 
> pos + " 1 char", regexp=True)> > to change the appearance of a block of text, 
> register the style using > tag_config, and then use tag_add to apply the 
> style tag to the block, e.g.:> > # do this when you create the widget> 
> text.tag_config("mystyle", foreground="red")> > # do this to apply this style 
> to a range of text> text.tag_add("mystyle", pos, end)> > hope this helps!> > 
> </F>> > _______________________________________________> Tkinter-discuss 
> mailing list> [email protected]> 
> http://mail.python.org/mailman/listinfo/tkinter-discuss
 
 
Hello Fredric,
 
Thank you for your answer. I am experiencing some problems with the code you 
suggested. The 
 
end = text.search("\W", pos + " 1 char", regexp=True)
gives me this as a result: TclError: bad text index " 1 char". I tried some 
other options for the " 1 char" 
part but the result was the same. Any ideas? I am using Windows XP and Python 
2.5.
 
Thanks again for the answer, 
 
Alex
_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces. 
It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to