Re: Dynamic text color

2010-01-08 Thread Dave McCormick
John Posner wrote: On Fri, 08 Jan 2010 14:28:57 -0500, MRAB wrote: The regex r'\bgreenList_regexp\b' will match the string 'greenList_regexp' if it's a whole word. What you mean is "any of these words, provided that they're whole words". You'll need to group the alternatives within "(?:...

Re: Dynamic text color

2010-01-08 Thread John Posner
On Fri, 08 Jan 2010 14:28:57 -0500, MRAB wrote: Dave McCormick wrote: On Wed, Jan 6, 2010 at 9:18 AM, John Posner > wrote: On Tue, 05 Jan 2010 16:54:44 -0500, Dave McCormick mailto:mackrac...@gmail.com>> wrote: But it is not what I am wanting.

Re: Dynamic text color

2010-01-08 Thread Dave McCormick
On Fri, Jan 8, 2010 at 12:28 PM, MRAB wrote: > Dave McCormick wrote: > >> >> >> On Wed, Jan 6, 2010 at 9:18 AM, John Posner > jjpos...@optimum.net>> wrote: >> >>On Tue, 05 Jan 2010 16:54:44 -0500, Dave McCormick >>mailto:mackrac...@gmail.com>> wrote: >> >>But it is not what I am w

Re: Dynamic text color

2010-01-08 Thread MRAB
Dave McCormick wrote: On Wed, Jan 6, 2010 at 9:18 AM, John Posner > wrote: On Tue, 05 Jan 2010 16:54:44 -0500, Dave McCormick mailto:mackrac...@gmail.com>> wrote: But it is not what I am wanting. I first thought to make it look for a space

Re: Dynamic text color

2010-01-08 Thread Dave McCormick
On Wed, Jan 6, 2010 at 9:18 AM, John Posner wrote: > On Tue, 05 Jan 2010 16:54:44 -0500, Dave McCormick > wrote: > > But it is not what I am wanting. I first thought to make it look for a >> space but that would not work when a single character like "#" is to be >> colored if there is a "string

Re: Dynamic text color

2010-01-06 Thread John Posner
On Tue, 05 Jan 2010 16:54:44 -0500, Dave McCormick wrote: But it is not what I am wanting. I first thought to make it look for a space but that would not work when a single character like "#" is to be colored if there is a "string" of them. Or if all of the characters between quotes are

Re: Dynamic text color

2010-01-06 Thread Neil Cerutti
On 2010-01-05, John Posner wrote: > 2. It's probably not the best idea to use a single variable > (you use "file") to do double-duty: to hold the name of a > file, and to hold the open-file object returned by the open() > function. It's perfectly legal, but it hides information that > might be

Re: Dynamic text color

2010-01-05 Thread Dave McCormick
John Posner wrote: On Tue, 05 Jan 2010 15:08:04 -0500, Dave McCormick wrote: It sounds like the program is doing exactly what you TOLD it to do (which might not be what you WANT it to do): 1. In an earlier pass on the text, color the string "dog" red. 2. In a later pass, color the strin

Re: Dynamic text color

2010-01-05 Thread John Posner
On Tue, 05 Jan 2010 15:08:04 -0500, Dave McCormick wrote: It's certainly a mistake to use the expression "str(rList).split()". Using str() to convert the list "rList" into a string creates a mess that includes square-bracket characters. Did this actually work for you? It sort of worked

Re: Dynamic text color

2010-01-05 Thread Dave McCormick
John Posner wrote: Dave, you're doing exactly the right thing: gradually expanding your program, to provide more functionality and to learn more about the available programming tools. It's also very good that you take care to close() the file after processing it. Now for the bad news ... S

Re: Dynamic text color

2010-01-05 Thread John Posner
On Tue, 05 Jan 2010 10:31:09 -0500, Dave McCormick wrote: ... But this is what I have so far. ## file = 'red.txt' file = open("red.txt","r") rList = file.readlines() file.close() redList = str(rList).split() Dave, you're doing exactly the right thing: gradually expanding your

Re: Dynamic text color

2010-01-05 Thread Dave McCormick
John Posner wrote: On Fri, 01 Jan 2010 21:01:04 -0500, Cousin Stanley wrote: I was not familiar with the re.finditer method for searching strings ... Stanley and Dave -- So far, we've just been using finditer() to perform standard-string searches (e.g. on the word "red"). Sinc

Re: Dynamic text color

2010-01-04 Thread John Posner
On Fri, 01 Jan 2010 21:01:04 -0500, Cousin Stanley wrote: I was not familiar with the re.finditer method for searching strings ... Stanley and Dave -- So far, we've just been using finditer() to perform standard-string searches (e.g. on the word "red"). Since Dave now wants to

Re: Dynamic text color

2010-01-03 Thread Cousin Stanley
> John Posner wrote > > I've posted a complete solution > > http://cl1p.net/jjp_dynamic_text_color/. John Thanks for posting your solution to Dave McCormick's query about colorizing text I was not familiar with the re.finditer method for search

Re: Dynamic text color

2010-01-03 Thread Dave McCormick
John, Interesting and confusing... I tested my code on Ubuntu 8.04, Win XP and 7, and WinMob before I called it "good". And of course your modifications work on all too. """ * rename get_position() to get_complete_text() * replace new_Rword(), new_Bword(), and new_Gword() with a single functi

Re: Dynamic text color

2010-01-02 Thread John Posner
On Sat, Jan 2, 2010 at 1:47 PM, Dave McCormick wrote: WooHoo!!! I got it!!! Yup, I am sure it can be optimized but it works!!! Hmmm ... it doesn't work for me ... RED for word in redList: new_Rword(complete, word) def new_Rword(complete, word): Tbox.tag_remov

Re: Dynamic text color

2010-01-02 Thread John Posner
On Sat, Jan 2, 2010 at 1:47 PM, Dave McCormick wrote: WooHoo!!! I got it!!! Yup, I am sure it can be optimized but it works!!! Dave, please ignore a couple of my bogus complaints in the previous message: ... you call function new_Rword() before you define it ... this version also has

Re: Dynamic text color

2010-01-02 Thread Dave McCormick
WooHoo!!! I got it!!! Yup, I am sure it can be optimized but it works!!! John, I have to admit that I spent several hours working on this before I looked at your example, then I spent another several hours getting this far. Would never have gotten it with out you help. Thanks!!! Also reading t

Re: Dynamic text color

2009-12-31 Thread Dave McCormick
Thanks John and Lie, This is supposed to color the word "red" red, "blue" blue, "green" green, etc... The idea is say for a database front end, the search words will be highlighted or colored when the query is returned. Another thing I want to try is a Program editor, something like IDLE. The

Re: Dynamic text color

2009-12-31 Thread John Posner
On Thu, 31 Dec 2009 10:24:44 -0500, Dave McCormick wrote: John, Thank you for the tips. I was changing the line-column index to a FLOAT because the search would return the starting position (pos) of the string, then by making it a FLOAT and adding the string length I was able to get the en

Re: Dynamic text color

2009-12-31 Thread Lie Ryan
On 1/1/2010 2:24 AM, Dave McCormick wrote: If I count characters from the beginning how do I know what line the text is on? Would you mind making your last hint a bit stronger... From http://infohost.nmt.edu/tcc/help/pubs/tkinter/text-index.html: """ + n chars From the given index, move f

Re: Dynamic text color

2009-12-31 Thread Dave McCormick
John, Thank you for the tips. I was changing the line-column index to a FLOAT because the search would return the starting position (pos) of the string, then by making it a FLOAT and adding the string length I was able to get the end position. If "red" was on line 1 column 0.. Tbox.ta

Re: Dynamic text color

2009-12-30 Thread John Posner
On Wed, 30 Dec 2009 12:58:06 -0500, Dave McCormick wrote: Hi All, I am new to Python and the list so I hope I am posting this correctly... I am working on a way to have text automatically formated in a Tkiniter Text widget and would like some input on my code. Currently I am using Python

Dynamic text color

2009-12-30 Thread Dave McCormick
Hi All, I am new to Python and the list so I hope I am posting this correctly... I am working on a way to have text automatically formated in a Tkiniter Text widget and would like some input on my code. Currently I am using Python 2.5 because the server I use has that installed. Tkinter is tk